customcombobox.h 510 B

123456789101112131415161718192021
  1. #ifndef CUSTOMCOMBOBOX_H
  2. #define CUSTOMCOMBOBOX_H
  3. #include <QComboBox>
  4. /**
  5. * @brief 使用此类绘制下拉框阴影需要在样式表中设置QAbstractItemView {margin: LISTVIEW_MARGIN;}
  6. */
  7. class CustomComboBox : public QComboBox
  8. {
  9. public:
  10. explicit CustomComboBox(QWidget *parent = nullptr);
  11. ~CustomComboBox();
  12. //重写下拉框弹出位置
  13. void showPopup() override;
  14. private:
  15. const int LISTVIEW_MARGIN = 8; // QAbstractItemView边距(阴影宽度)
  16. };
  17. #endif // CUSTOMCOMBOBOX_H