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 ?
Re: QToolButton text alignment
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.
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).
Re: QToolButton text alignment
Quote:
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 ?
Re: QToolButton text alignment
Quote:
Originally Posted by
Vladimir
It doesn't look like a toolbar, at least in Qt Designer... But it doesn't mean it's not one :)
Quote:
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.
Re: QToolButton text alignment
Quote:
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.