Results 1 to 3 of 3

Thread: QToolbar setContentsMargins

  1. #1
    Join Date
    Feb 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QToolbar setContentsMargins

    While trying to upgrade from Qt 4.1.2 to 4.3.1, I ran into a problem with my toolbar. I have two icons I always want to display all the way on the right of my toolbar like this: , and I was able to do that in 4.1.2 by doing some calculations and then setting the contents margins on my rightmost toolbar (the one containing the two icons) so the left margin would be just the right size to position the icons all the way on the right. This doesn't seem to work in 4.3.1. I even tried getting the tool bar's layout and setting its contents margin, but that didn't work either, I always get this: . Any help?

  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 setContentsMargins

    Try adding a dummy expanding widget as first item in the tool bar:
    Qt Code:
    1. // a dummy expanding widget
    2. QWidget* widget = new QWidget(toolBar);
    3. widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    4. toolBar->addWidget(widget);
    5. // add real actions
    6. tooBar->addAction(...);
    7. ...
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. #3
    Join Date
    Feb 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Talking Re: QToolbar setContentsMargins

    wow, very simple - worked great. thx, jpn.

Similar Threads

  1. QToolBar
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 14th September 2007, 19:48
  2. Various icon sizes for QToolButtons on QToolbar
    By Erlendhg in forum Qt Programming
    Replies: 4
    Last Post: 30th June 2007, 18:35
  3. How Do I Float a QToolBar?
    By dvmorris in forum Qt Programming
    Replies: 7
    Last Post: 29th April 2007, 19:01
  4. QToolBar in a new UI form?
    By gfunk in forum Qt Tools
    Replies: 7
    Last Post: 2nd June 2006, 11:19
  5. Insert separate QToolBar into QMainWindow
    By YuriyRusinov in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 10:37

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.