QToolButton Layout Inversion

I would like to do QToolButtonwhere the text remains to the left of its icon. I tried to find the relevant information and tried:

button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

but this sets the text on the right side of the button. I studied stylish style sheets, but text alignment is for buttons only. Is there any way to do this?

My goal at the highest level is to create an interface panel that looks like this:

goal

with a text label and an image next to it. I am currently using a toolbar with custom buttons due to the style (without borders except moused-over, it still has indentation with validation, contains text and an icon ...). It is possible that I am using the wrong type of widgets, so if I cannot change the layout of this, is there any way to imitate this style?

This is what I have:

current.

+3
2

QWidget::setLayoutDirection:

toolbar->setLayoutDirection(Qt::RightToLeft);
+4

, , QWidget. QLabel QToolButton ( QPushButton), QHBoxLayout. QToolBar::addWidget() QToolBar::insertWidget().

, :

#include <QtGui>

class CoolButton : public QWidget
{
public:
    CoolButton(QWidget *parent = 0) : QWidget(parent)
    {
        QLabel *label = new QLabel("Hi!", this);
        QToolButton *button = new QToolButton(this);
        QHBoxLayout *layout = new QHBoxLayout;
        layout->addWidget(label);
        layout->addWidget(button);
        setLayout(layout);
    }
};
+1

All Articles