//++ ------------------------------------------------------------------------------------
void RDWinWithWinMenuBtn_c
::paintEvent( QPaintEvent * /*vpEvent*/ ) {
// RD_DEV_IOR_FACT
// The colorGroup parameter in drawComplexControl appears not to be used (look at Qt source code)
// so doing this
// QColorGroup colorGrp; <- default all black
// makes not difference to the button color!!
//
// Also style does not change when windows theme changes. Is this not the idea of QStyles?
//style().drawComplexControl( QStyle::CC_ToolButton, &painter, this, rect(), colorGroup() );
// Test code to change to ANY color or style! Not!
QColorGroup cga = pl.active();
QColorGroup cgi = pl.inactive();
QColorGroup cgBtn;
if( hasMouse() )
{
if( m_bBtnIsClicked )
{
cga.
setColor( QColorGroup
::Background,
QColor( Qt
::green ) );
cgBtn = cga;
}
else
{
cgi.
setColor( QColorGroup
::Background,
QColor( Qt
::blue ) );
cgBtn = cgi;
}
}
pl.setActive( cga );
pl.setInactive( cgi );
setPalette( pl );
style
().
drawControl( QStyle::CE_PushButton,
&painter,
this, rect
(), cgBtn, sf
);
}
void RDWinWithWinMenuBtn_c
::mousePressEvent( QMouseEvent * vpEvent
) {
m_bBtnIsClicked = true;
}
void RDWinWithWinMenuBtn_c
::mouseReleaseEvent( QMouseEvent * vpEvent
) {
m_bBtnIsClicked = false;
}
//++ ------------------------------------------------------------------------------------
void RDWinWithWinMenuBtn_c::paintEvent( QPaintEvent * /*vpEvent*/ )
{
// RD_DEV_IOR_FACT
// The colorGroup parameter in drawComplexControl appears not to be used (look at Qt source code)
// so doing this
// QColorGroup colorGrp; <- default all black
// makes not difference to the button color!!
//
// Also style does not change when windows theme changes. Is this not the idea of QStyles?
QPainter painter( this );
//style().drawComplexControl( QStyle::CC_ToolButton, &painter, this, rect(), colorGroup() );
// Test code to change to ANY color or style! Not!
QStyle::SFlags sf = QStyle::Style_Raised;
QPalette pl = palette();
QColorGroup cga = pl.active();
QColorGroup cgi = pl.inactive();
QColorGroup cgBtn;
if( hasMouse() )
{
if( m_bBtnIsClicked )
{
sf = QStyle::Style_Down;
cga.setColor( QColorGroup::Background, QColor( Qt::green ) );
cgBtn = cga;
}
else
{
sf = QStyle::Style_HasFocus;
cgi.setColor( QColorGroup::Background, QColor( Qt::blue ) );
cgBtn = cgi;
}
}
pl.setActive( cga );
pl.setInactive( cgi );
setPalette( pl );
style().drawControl( QStyle::CE_PushButton, &painter, this, rect(), cgBtn, sf );
}
void RDWinWithWinMenuBtn_c::mousePressEvent( QMouseEvent * vpEvent )
{
m_bBtnIsClicked = true;
}
void RDWinWithWinMenuBtn_c::mouseReleaseEvent( QMouseEvent * vpEvent )
{
m_bBtnIsClicked = false;
}
To copy to clipboard, switch view to plain text mode
Bookmarks