Results 1 to 2 of 2

Thread: Newbie question about QToolBar

  1. #1
    Join Date
    Apr 2010
    Qt products
    Unix/X11 Windows Symbian S60

    Default Newbie question about QToolBar

    Hello all,

    I created a gui for my application like those of qtcreator where a QToolBar is placed on left side with several push button that switch app's central widget. Now i'd like to add another QToolBar placed just on right of the first one to create a submenu. I wrote this little snippet of code to show how QToolBar looks like:

    Qt Code:
    1. class MainWindow: public QMainWindow
    2. {
    3. Q_OBJECT
    5. public:
    6. MainWindow(QWidget *parent=0);
    7. void createActions();
    9. private:
    10. QToolBar *tb;
    11. QToolBar *tab;
    12. QAction *quitAction;
    13. };
    15. MainWindow::MainWindow(QWidget *parent)
    16. {
    17. createActions();
    19. tb = new QToolBar();
    20. tb->setFloatable(false);
    21. tb->setMovable(false);
    22. addToolBar(Qt::LeftToolBarArea,tb);
    23. tb->setAllowedAreas(Qt::LeftToolBarArea);
    24. tb->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
    25. tb->setOrientation(Qt::Horizontal);
    26. tb->addAction(quitAction);
    28. tab = new QToolBar();
    29. tab->setFloatable(false);
    30. tab->setMovable(false);
    31. tab->setAllowedAreas(Qt::LeftToolBarArea);
    32. tab->setOrientation(Qt::Horizontal);
    33. tab->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
    34. addToolBar(Qt::LeftToolBarArea,tab);
    35. tab->addAction(quitAction);
    36. }
    To copy to clipboard, switch view to plain text mode 

    but QToolBar are below the other instead of one near the other. Is it possible to achive what i need, with QToolBar, and how?

    I added a screenshot to show how i'd like the effect looks like.

    Thanks for any advice.
    Last edited by AlbertoN; 24th May 2012 at 14:17.

  2. #2
    Join Date
    Feb 2011
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    MacOS X Windows

    Default Re: Newbie question about QToolBar

    Why are you using horizontal orientation?

Similar Threads

  1. REAL Newbie question -- where to go from here?
    By scott_hollen in forum Newbie
    Replies: 4
    Last Post: 21st January 2011, 09:35
  2. Newbie Question with Qextserialport.tar.gz
    By nomad in forum Qt-based Software
    Replies: 2
    Last Post: 13th July 2009, 14:32
  3. Newbie Designer question
    By JariV in forum Qt Tools
    Replies: 0
    Last Post: 15th February 2009, 23:24
  4. QAbstractItemModel newbie question
    By okellogg in forum Qt Programming
    Replies: 14
    Last Post: 18th February 2008, 13:30
  5. Newbie threading question
    By deepayan in forum Qt Programming
    Replies: 17
    Last Post: 16th April 2007, 01:25


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.