I managed to find a solution to this.
By simply drawing the pixmap rather than the control element I am able to produce th desired results. The mouse press event for the parent widget can allow me to detect mouse clicks over the m_checkboxRect area and therefore maintain the checked state.
switch (m_checkboxState)
{
case Qt::Checked:
option.
state = QStyle::State_On;
indicatorPixmap
= QPixmap(":/Resources/indicator_on.png");
break;
case Qt::Unchecked:
option.
state = QStyle::State_Off;
indicatorPixmap
= QPixmap(":/Resources/indicator_off.png");
break;
case Qt::PartiallyChecked:
option.
state = QStyle::State_NoChange;
indicatorPixmap
= QPixmap(":/Resources/indicator_partial.png");
break;
default:
break;
}
style()->drawItemPixmap(painter, m_checkboxRect, 0, indicatorPixmap );
switch (m_checkboxState)
{
case Qt::Checked:
option.state = QStyle::State_On;
indicatorPixmap = QPixmap(":/Resources/indicator_on.png");
break;
case Qt::Unchecked:
option.state = QStyle::State_Off;
indicatorPixmap = QPixmap(":/Resources/indicator_off.png");
break;
case Qt::PartiallyChecked:
option.state = QStyle::State_NoChange;
indicatorPixmap = QPixmap(":/Resources/indicator_partial.png");
break;
default:
break;
}
style()->drawItemPixmap(painter, m_checkboxRect, 0, indicatorPixmap );
To copy to clipboard, switch view to plain text mode
Bookmarks