Setting background image for QPushButton

Posted by Surjya Narayana Padhi on Stack Overflow See other posts from Stack Overflow or by Surjya Narayana Padhi
Published on 2010-04-20T00:47:15Z Indexed on 2010/04/20 0:53 UTC
Read the original article Hit count: 695

Filed under:
|
|

Hi Geeks,

I am struggling to set an background image for an QPushButton. No Success till now. Following is my code.

appsWidget::appsWidget(QWidget *parent)
    :QWidget(parent)
{
    QPushButton *button1 = new QPushButton("SETTINGS",this);
    QPushButton *button2 = new QPushButton("TEST",this);
    QPushButton *button3 = new QPushButton("IE",this);

    button1->setStyleSheet("background-image:url(config.png)"); -> No success


    qDebug("appWidget initialized.");

    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget(button1);
    layout->addWidget(button2);
    layout->addWidget(button3);
    this->setLayout(layout);
    connect(button1,SIGNAL(clicked()),this,SLOT(setClickIndex1()));
    connect(button2,SIGNAL(clicked()),this,SLOT(setClickIndex2()));
    connect(button3,SIGNAL(clicked()),this,SLOT(setClickIndex3()));
}

The image I am using in the stylesheet is located in the same project folder. Do anybody has any solution?

© Stack Overflow or respective owner

Related posts about qt4

Related posts about background