[M]增加刷新样式接口,同时在设置是否编辑时,调用刷新样式函数。解决问题:下拉框加载样式后,setEditable后需要重新加载样式,才能生效

This commit is contained in:
shijianquan 2025-05-07 16:45:56 +08:00
parent e7bb58ddf9
commit 881e4f3079

View File

@ -34,6 +34,14 @@ public slots:
{
addItem(text, userData);
}
void refreshStyle()
{
this->style()->unpolish(this);
this->style()->polish(this);
this->update();
}
void insertOneItem(int index, const QString &text, QString userData = "")
{
insertItem(index, text, userData);
@ -57,6 +65,7 @@ public slots:
void setEditabled(bool editable)
{
setEditable(editable);
refreshStyle();
}
QString getCurrentText()
{
@ -696,6 +705,13 @@ public:
explicit CCheckBox(QWidget *parent = Q_NULLPTR);
explicit CCheckBox(const QString &text, QWidget *parent = Q_NULLPTR);
public slots:
void refreshStyle()
{
this->style()->unpolish(this);
this->style()->polish(this);
this->update();
}
protected:
virtual bool event(QEvent *e) Q_DECL_OVERRIDE;
};