Results 1 to 10 of 10

Thread: Position of qActions inside a QToolBar

  1. #1
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Position of qActions inside a QToolBar

    Hi,

    I have a QToolBar with seven "buttons" on it, I didn't want to have a normal menu (File, Edit, Tools...) as I just needed few buttons, I created seven QActions inside, working as buttons.

    I would like to ask if I could move them, for instance, the first five in the left side of the screen and the last two in the right side.

    I'd prefer to keep this structure because QToolBar is movable, it floats... really confortable for the user of the application.

    Thanks!

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

    Default Re: Position of qActions inside a QToolBar

    Create two toolbars - one with the first five actions and the other one with the remaining two. Then you can move them around freely.
    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.


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

    jano_alex_es (4th June 2009)

  4. #3
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: Position of qActions inside a QToolBar

    yep, that was something I was trying as well... but changing the X coordenade of "Geometry" didn't affect its position at all.

    In the end, I just needed to set LyoutDirection(Right to Left) in the right one.

  5. #4
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: Position of qActions inside a QToolBar

    It works fine when the toolbar is settled horizontaly... but if you move both toolbar vertically the second one shows always its actions in its upper part... but I'd like to have them in the lower part...





  6. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Position of qActions inside a QToolBar

    Without any testing and promise that it could work:

    Use a third bar where you set a expanding spacer via QToolBar::addWidget(). Then use the signal which informs you if tool bars have changed and make sure that that spacer tool bar is always between the two others.


    AGAIN: I don't have a clue if that is working, came just in my mind. Could work...

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

    Default Re: Position of qActions inside a QToolBar

    It's probably better to have one bar with an extra widget using heightForWidth. Provided it would work at all
    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.


  8. #7
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Position of qActions inside a QToolBar

    Quote Originally Posted by wysota View Post
    It's probably better to have one bar with an extra widget using heightForWidth. Provided it would work at all
    And again I am feeling ashamed because I have only read "Adds the given widget to the toolbar as the toolbar's last item." and was only thinking that with the second toolbar alone it won't work, ignoring one could also use the first one...

    So jano_alex_es it's up to you to try if this works and please notice us.

  9. #8
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    1

    Default Re: Position of qActions inside a QToolBar

    To align to the right I used this as a widget/spacer.
    This QToolbar shuld have an addSpacer() or similar

    ## Spacer widget
    w = QtGui.QWidget()
    sp = QtGui.QSizePolicy()
    sp.setHorizontalPolicy( QtGui.QSizePolicy.Expanding )
    w.setSizePolicy( sp )
    toolbar.addWidget( w )

  10. #9
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: Position of qActions inside a QToolBar

    Seems like it's not working either

    Qt Code:
    1.  
    2. //first try
    3. //w.setMinimumWidth(100);
    4.  
    5. //second try, with all the different flag possibilities
    6. /*QSizePolicy sp;
    7. sp.setHorizontalPolicy( QSizePolicy::Expanding);
    8. sp.setVerticalPolicy( QSizePolicy::Expanding);
    9.  
    10. w.setSizePolicy( sp );*/
    11.  
    12. ui.toolBar2->insertWidget(ui.firstQActionInTheSecondToolbar, &w);
    To copy to clipboard, switch view to plain text mode 

    I'll try the third toolbar with a widget expanding which will be always before the second toolbar.

  11. #10
    Join Date
    Jun 2006
    Posts
    74
    Thanks
    6
    Thanked 4 Times in 3 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Position of qActions inside a QToolBar

    Sorry for digging out this ancient threat, but I have the exact same problem. Any solution by now?

    I can prevent expansion of the second toolbar by calling
    Qt Code:
    1. secondToolbar->layout()->setSizeConstraint(QLayout::SetFixedSize);
    To copy to clipboard, switch view to plain text mode 
    but the same approach won't help expand the first toolbar with either constraint. Plus, this will fix both width and height, which is not really what you want.

    Thanks for your consideration.

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.