Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
4.4.0
-
None
Description
In Qt 4.4, a small arrow is automatically drawn on a QToolButton when that button has a menu. This arrow does not exist in Qt 4.3.
It is not possible to remove this small arrow without reimplemetning the paintEvent() of QToolButton and manually changing the QStyleOptionToolButton.
This small arrow may be useful to some, however, setArrowType() is commonly used to display an arrow on the button. The combination of both arrows is not very nice and can in fact be confusing if one arrow points up and the other points down.
It would be expected that this small automatically placed arrow could be turned off.
WORKAROUND:
//---------------------------------
#include <QtGui>
class Button : public QToolButton
{
public:
Button( QWidget * parent = 0 ) : QToolButton( parent ) { }
protected:
virtual void paintEvent( QPaintEvent * )
{ QStylePainter p( this ); QStyleOptionToolButton opt; initStyleOption( & opt ); opt.features &= (~ QStyleOptionToolButton::HasMenu); p.drawComplexControl( QStyle::CC_ToolButton, opt ); }
};
int main( int argc, char * argv[] )
{
QApplication app( argc, argv );
QTabWidget * tabWid = new QTabWidget;
Button * but = new Button( tabWid );
but->setArrowType( Qt::DownArrow );
QMenu * menu = new QMenu( but );
menu->addAction( "Item 1" );
menu->addAction( "Item 2" );
but->setMenu( menu );
but->setPopupMode( QToolButton::InstantPopup );
tabWid->addTab( new QTextEdit, "Hello" );
tabWid->addTab( new QTextEdit, "World" );
tabWid->setCornerWidget( but, Qt::TopRightCorner );
tabWid->show();
return app.exec();
}
//---------------------------------