Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QPushButton text, icon and stylesheets



  • 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:
    0_1525784845337_StereoControlCenter 2018-05-08 16.04.48.png

    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


  • Qt Champions 2019


Log in to reply