QPushButton text, icon and stylesheets
Unsolved
General and Desktop
-
Hi there.
I have my own class named IconButton.
This class contains QLabel* as member.
This method allow me very flexible interface with accessing button or label.
Also i can use custom stylesheets for label and for button.Code part:
class wIconButton : public QPushButton, public wWidget { Q_OBJECT ... protected: ... QLabel* m_overlay_label; };
wIconButton::wIconButton(const QString& name) : wWidget(name) , m_sub(0) { ... m_overlay_label = new QLabel(this); m_overlay_label->setObjectName("l_blue_gr"); m_overlay_label->setText("test"); }
Button created with this class looks like:
So main question is:
Can i draw button like mine without additional Qlabel object?
(and without tons of code)What i need from button:
Specify text position (bottom, top...)
Specify text color (font size)
Specify gradient to label -
@goldstar2154 Yes, you can draw, see http://doc.qt.io/qt-5/qwidget.html#paintEvent and http://doc.qt.io/qt-5/qpainter.html