Results 1 to 7 of 7

Thread: QToolButton text alignment

  1. #1
    Join Date
    Jan 2007
    Posts
    45
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QToolButton text alignment

    Hello All !
    I'm trying to implement toolbox which looks like widgets palette from Qt3 Desiger. I've created QToolBar and set its orientation to Vertical. For each added button I'm setting
    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    But in Qt4 a text on buttons are centered ! Are there any way to set text alignment for QToolButton ? Or maybe there are better ways to implement such toolbox ?

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

    Default Re: QToolButton text alignment

    Can't you use QToolBox?

  3. #3
    Join Date
    Jan 2007
    Posts
    45
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QToolButton text alignment

    Yes, I'm using it. My question was about content inside QToolBox.
    I've already found a solution: QToolButton aligns text to left if it has icon and QToolBar is in Qt::ToolButtonTextBesideIcon mode.
    Anyway, thanks for your reply.

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

    Default Re: QToolButton text alignment

    The contents is most probably a QListView, at least it looks like one (notice the scrollbars if you reduce the toolbox size).

  5. #5
    Join Date
    Jan 2007
    Posts
    45
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QToolButton text alignment

    The contents is most probably a QListView, at least it looks like one (notice the scrollbars if you reduce the toolbox size).
    According to function void MainWindow::setupToolbox() in
    http://websvn.kde.org/tags/kdevelop/...88&view=markup
    it must be QToolBar. But it has scrollbars, this really puzzles me !

    With QListView its quite harder to implement toggle items like in designer3, isn't it ?

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

    Default Re: QToolButton text alignment

    Quote Originally Posted by Vladimir View Post
    According to function void MainWindow::setupToolbox() in
    http://websvn.kde.org/tags/kdevelop/...88&view=markup
    it must be QToolBar. But it has scrollbars, this really puzzles me !
    It doesn't look like a toolbar, at least in Qt Designer... But it doesn't mean it's not one

    With QListView its quite harder to implement toggle items like in designer3, isn't it ?
    No, why? You know when the item is selected or activated and then it's just a matter of painting it. With Qt4 it's even easier - QStyleOptionViewItem contains the full state of the item, along with its selected state (QStyle::State_Selected). Then you can paint the item accordingly.

  7. #7
    Join Date
    Jan 2007
    Posts
    45
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QToolButton text alignment

    No, why? You know when the item is selected or activated and then it's just a matter of painting it. With Qt4 it's even easier - QStyleOptionViewItem contains the full state of the item, along with its selected state (QStyle::State_Selected). Then you can paint the item accordingly.
    Ok, maybe QListView fits better for may task. I'll try using it.
    And thanks a lot for you suggestion.

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 14:36
  3. Editable text in QGraphicsView
    By wysota in forum Qt Programming
    Replies: 8
    Last Post: 24th February 2007, 15:30
  4. visible text of textedit
    By regix in forum Qt Programming
    Replies: 3
    Last Post: 26th June 2006, 09:02
  5. Icon Text Alignment
    By nupul in forum Newbie
    Replies: 3
    Last Post: 1st May 2006, 04:47

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.