Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-2036

Setting/unsetting menu arrow on QToolButton

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • Some future release
    • 4.4.0
    • GUI: Look'n'Feel
    • 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();
      }
      //---------------------------------

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            gpf Shane McLaughlin
            Veli-Pekka Heinonen Veli-Pekka Heinonen
            Votes:
            16 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes