Image is not displaying on pushbutton

  • Hi Everyone,

    I want to add an image on push button to look as a icon, below is the code. The only problem is the app is running without a single error but the image is not being displayed on the button

    Code: (Overview.cpp)
    #include "overview.h"
    #include "ui_overview.h"
    #include <QFile>
    #include <QMessageBox>

    Overview::Overview(QWidget *parent) :
    ui(new Ui::Overview)

    QString fileName("D:/solar4000/QT/images/actual.png");
    if(QFile(fileName).exists() == false)
    QMessageBox::warning(this, "Application", "Wrong file name : " + fileName);



    delete ui;


  • Moderators

    Please check out the "code wrapping possibility": of Qt. This makes your code better readable.

  • I think now its readable so can be answered

  • I have closed your other topic on this same issue. Please stick to one topic per question. Double posting is not acceptable.

    What is myButton exactly? You call ui->setupUi(this), but your button does not seem to be part of your ui? I would have expected to see something like:

  • I did want to remove it but didn't find any option.
    myButton was the new pushbutton which I tried to add in ui through code....defined it in header file...

  • So... show us the relevant code please!

    Removing of topics can only be done by admins on this forum.

  • Actually there is one button in ui also but i tried to put image on the button which i created through code by defining the pushbutton... I tried the one you told it worked for me...Thanks a lot

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.