1234567891011121314151617181920212223242526 |
- #ifndef CUSTOMCOMBOBOX_H
- #define CUSTOMCOMBOBOX_H
- #include <QComboBox>
- /**
- * @brief 1、使用此类绘制下拉框阴影需要在样式表中设置QAbstractItemView {margin: LISTVIEW_MARGIN;}
- * 否则阴影会被遮挡
- * 2、调用函数setViewShadowEffect()设置下拉框阴影
- */
- class CustomComboBox : public QComboBox
- {
- public:
- explicit CustomComboBox(QWidget *parent = nullptr);
- ~CustomComboBox();
- /* 设置下拉框阴影 */
- void setViewShadowEffect();
- //重写下拉框弹出位置
- void showPopup() override;
- private:
- const int LISTVIEW_MARGIN = 12; // QAbstractItemView边距(阴影宽度)
- };
- #endif // CUSTOMCOMBOBOX_H
|