Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.5.1
-
None
-
Windows 7, C++, VS2010
Description
I subclassed a QLineEdit and added an action.
The action has an icon which is set in the stylesheet via qproperty-action_icon. The stylesheet defines also a style for the read-only pseudo state.
Toggling read-only with setReadOnly( bool ) toggles the background color but not the action icon.
class QMyLineEdit : public QLineEdit { Q_OBJECT Q_PROPERTY( QString action_icon READ GetIcon WRITE SetIcon ) public: explicit QMyLineEdit( QWidget* parent ) : m_pAction( nullptr ) { m_pAction = new QAction( this ); connect( m_pAction, &QAction::triggered, this, &QMyLineEdit::MyAction ); addAction( m_pAction, QLineEdit::TrailingPosition ); } private: QAction* m_pAction; QString m_strIcon; const QString& GetIcon() const { return m_strClearIcon; } void SetIcon( const QString& strIcon ) { m_strIcon = strIcon; QIcon Icon( m_strIcon ); m_pAction->setIcon( Icon ); } void MyAction(){ /* ... */ } };
// Stylesheet
.QMyLineEdit {
qproperty-action_icon: url(:/Widgets/action.png);
}
.QMyLineEdit:read-only {
background-color: green;
qproperty-action_icon: url(:/Widgets/action_readonly.png);
}
Attachments
Issue Links
- relates to
-
QTBUG-2982 StyleSheet re-apply "qproperty-" and co. on pseudo state changes.
- Closed