Results 1 to 6 of 6

Thread: right justify toolbar

  1. #1
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default right justify toolbar

    How can I get the widgets I add to QToolBar of a QMainWindow to be justified to the right?

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: right justify toolbar

    You can try using QToolBar::layout()->setAlignment().
    But I don't guarantee that it will work. It is just an assumption.

    Regards

  3. The following user says thank you to marcel for this useful post:

    magland (14th July 2007)

  4. #3
    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: right justify toolbar

    Or you could add a dummy widget with QSizePolicy::Expanding in front.
    J-P Nurmi

  5. The following 2 users say thank you to jpn for this useful post:

    magland (14th July 2007), vycke (16th April 2008)

  6. #4
    Join Date
    Feb 2007
    Location
    Philadelphia, USA
    Posts
    255
    Thanks
    43
    Thanked 21 Times in 21 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: right justify toolbar

    Quote Originally Posted by jpn View Post
    Or you could add a dummy widget with QSizePolicy::Expanding in front.
    Thanks, that did the trick. Much appreciated.

    I did not try marcel's suggestion, but that may well have worked too... so thanks to both.

  7. #5
    Join Date
    Dec 2007
    Location
    Austin, TX
    Posts
    43
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: right justify toolbar

    Quote Originally Posted by jpn View Post
    Or you could add a dummy widget with QSizePolicy::Expanding in front.
    I actually wound up using (on a QDialog, not QMainWindow):
    Qt Code:
    1. m_vBoxLayout = new QVBoxLayout(this);
    2. m_hBoxLayout = new QHBoxLayout();
    3. m_vBoxLayout->addLayout(m_hBoxLayout);
    4. m_vBoxLayout->addStretch(1);
    5. m_hBoxLayout->insertStretch(0, 1);
    6. m_hBoxLayout->addWidget(m_toolBar);
    To copy to clipboard, switch view to plain text mode 

    Which places my toolbar at the top/right of the dialog.

    Vycke

  8. #6
    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: right justify toolbar

    Quote Originally Posted by vycke View Post
    I actually wound up using (on a QDialog, not QMainWindow):

    Which places my toolbar at the top/right of the dialog.
    But the original question was about aligning items IN the toolbar, not the toolbar itself. Furthermore, with QDialog you lose all the functionality QMainWindow has to offer for toolbars like ability to move toolbars.
    J-P Nurmi

Similar Threads

  1. Adding a toolbar to a TableWidget
    By Walter in forum Qt Programming
    Replies: 2
    Last Post: 1st July 2007, 21:13
  2. Replies: 4
    Last Post: 25th June 2007, 20:40
  3. how i can add image in my toolbar
    By jyoti in forum Qt Tools
    Replies: 7
    Last Post: 19th December 2006, 14:39
  4. Initialise toolbar in a different area
    By georgie in forum Qt Programming
    Replies: 4
    Last Post: 4th May 2006, 03:49
  5. animating a toolbar??!?
    By nupul in forum Qt Programming
    Replies: 4
    Last Post: 1st April 2006, 08:27

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.