Results 1 to 7 of 7

Thread: Vertical QToolBar

  1. #1
    Join Date
    Jan 2012
    Posts
    15
    Thanks
    4
    Qt products
    Qt4

    Default Vertical QToolBar

    Hi everyone!
    I hope i can get some help here. I'm trying to align the QActions in vertical QToolbar to the left, but i don't know how to achieve this.
    I got a QToolbar with ->setOrientation( Qt::Vertical ) and setToolButtonStyle(Qt::ToolButtonTextBesideIcon)
    I am adding QActions with addAction(). All QActions are aligned centered, how can i have them all aligned to the left?
    Thanks for any help.

  2. #2
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Vertical QToolBar

    If you are using designer, simply drag the toolbar. QToolBar::setOrientation should not be used when the toolbar is used with mainwindow. Use QMainWindow::addToolBar and QMainWindow::insertToolBar to move it around.

  3. #3
    Join Date
    Jan 2012
    Posts
    15
    Thanks
    4
    Qt products
    Qt4

    Default Re: Vertical QToolBar

    Hi thanks for your answer but it seems my questions was not precise enough.
    I'm not having a problem making a QToolBar vertical. This works perfectly. I'm adding a QToolBar to a QDockWidget programmatically which is on the left side of the aplication window.
    The problems begin when i start to add QActions to this QToolBar:
    The QActions are all centered horizontally, but i want them to be aligned to the left inside the QToolbar.

  4. #4
    Join Date
    Nov 2013
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Vertical QToolBar

    I am having the same issue. When moving a QToolBar to a vertical position the QActions within the toolbar are "center" aligned. I have attached an image showing what is happening. Anyone have a clue as to how these actions can be left or right aligned? This is part of a form created within QT Designer.

    thanks,
    toolbar.png

  5. #5
    Join Date
    Apr 2016
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Vertical QToolBar

    has someone solved this issue?

  6. #6
    Join Date
    Jan 2018
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Vertical QToolBar

    In designer you have to drag the toolbar towards the middle left side of the window. When the area lights up blue you can let go.

  7. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Vertical QToolBar

    In designer you have to drag the toolbar towards the middle left side of the window. When the area lights up blue you can let go
    Your answer has nothing to do with the problem. The problem is not "How do I add a vertical toolbar when using Qt Designer?", it is "When I add a vertical toolbar, how do I get the icons and text to be left justified instead of centered?"

    As for the original question, I think one solution would be to derive a custom QToolButton and override the QToolButton::paintEvent() to draw the icon and text with the desired alignment. In this case, you would use QToolBar::addWidget() to insert the buttons and not one of the QToolbar::addAction() methods (since these will insert a standard QToolButton and not your custom one).
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. vertical slider
    By TomASS in forum Newbie
    Replies: 4
    Last Post: 29th November 2009, 00:30
  2. vertical scroll bar in Qt box.
    By rajveer in forum Qt Programming
    Replies: 1
    Last Post: 22nd October 2008, 07:41
  3. Vertical QTabBar
    By OriginalCopy in forum Qt Programming
    Replies: 4
    Last Post: 5th November 2007, 13:24
  4. 4.3: Styling vertical QSlider
    By Angelo Moriconi in forum Qt Programming
    Replies: 4
    Last Post: 18th June 2007, 16:04
  5. Vertical QLabel
    By ToddAtWSU in forum Qt Programming
    Replies: 4
    Last Post: 12th September 2006, 14:14

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.