Results 1 to 2 of 2

Thread: Qt Toolbutton with button stack

  1. #1
    Join Date
    Feb 2012
    Posts
    4
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Qt Toolbutton with button stack

    Hi,

    Here is what I am trying to do:

    I need a toolbar, with toolbuttons, some of these tool buttons are button stacks. i.e the button icon appears along with a right arrow, right clicking on this button whould open a grid layout of buttons. I looked at the QToolButton function setMenu, this opens up a popup menu alright, but it does not show me this arrow symbol that I am looking for alongside the icon to indicate to the user that this is a special tool button stack. Here is the code snippet I used:

    fileToolBar = addToolBar(tr("File"));

    tb2 = new QToolButton(fileToolBar);
    QMenu test(tb2);

    openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);

    test.addAction(openAct);
    tb2->setMenu(&test);

    tb2->setIcon(QPixmap( ":/images/open.png"));
    tb2->setArrowType(Qt:ownArrow);
    fileToolBar->insertWidget(newAct,tb2);

    In the above case I dont see the button icon on the toolbutton, instead I see only the down arrow symbol, clicking which opens up the popup menu. If the skip the setArrowType line, I can see only the icon and not the arrow. How can I achieve both the icon as well as the arrow on a toolbutton? I can manually draw this arrow within the paint Event of the button, but this is not called on the toolbar resize when the extension widgets appear (when we shrink the toolbar so that the toolbutton stack is not visible), so its of no use.

    Any help here would be greatly appreciated.

    Thanks in advance,
    Sangeeta.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt Toolbutton with button stack

    Objects created on the stack (like your "test") go out of scope when the block they are declared in ends.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. pushButton and toolButton
    By lucasbemo in forum Newbie
    Replies: 4
    Last Post: 11th February 2013, 09:37
  2. Set a ToolButton Hovered
    By vajindarladdad in forum Newbie
    Replies: 7
    Last Post: 1st September 2009, 12:33
  3. Toolbutton odd sizes
    By andytork in forum Qt Programming
    Replies: 0
    Last Post: 21st January 2009, 06:25
  4. how exclusive toolbutton in toolbar
    By irmakci in forum Qt Programming
    Replies: 2
    Last Post: 30th July 2008, 22:33
  5. Dockwidget and Toolbutton
    By sandeepvl in forum Qt Programming
    Replies: 3
    Last Post: 13th May 2008, 07:23

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.