Results 1 to 4 of 4

Thread: QToolBar help please

  1. #1
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QToolBar help please

    Is there a way by which I can put few widgets right aligned and few widgets left aligned in a QToolBar with the some eampty space in the center of the toolbar?

    Thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QToolBar help please

    Sure, QToolBar allows any widget to be inserted.

    Qt Code:
    1. // a dummy widget taking as much horizontal space as possible
    2. QWidget* spacer = new QWidget(toolBar);
    3. spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
    4.  
    5. toolBar->addAction("Action 1");
    6. toolBar->addWidget(spacer); // a "spacer" between actions
    7. toolBar->addAction("Action 2");
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QToolBar help please

    Oh, I did not notice that. In that case, can I use QLayout to place widgets on tool bar?

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QToolBar help please

    Quote Originally Posted by munna
    In that case, can I use QLayout to place widgets on tool bar?
    Yep, you can. Just wrap the layout inside a single widget which you place in a tool bar.
    J-P Nurmi

Similar Threads

  1. QToolBar in a new UI form?
    By gfunk in forum Qt Tools
    Replies: 7
    Last Post: 2nd June 2006, 12:19
  2. Insert separate QToolBar into QMainWindow
    By YuriyRusinov in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 11:37
  3. Is possible to hide a separator in a QToolBar?
    By Dark_Tower in forum Qt Programming
    Replies: 2
    Last Post: 20th April 2006, 11:03
  4. QToolBar go away! On startup anyway.
    By bitChanger in forum Qt Programming
    Replies: 1
    Last Post: 10th February 2006, 19:22

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.