[closed] Image is not displaying on pushbutton



  • Hi Everyone,

    I want to add an image on push button, 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
    Can anyone tell me what is wrong in the code.....Resource file is properly added and also the path is correct

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

    Overview::Overview(QWidget *parent) :
        QMainWindow(parent),
    ui(new Ui::Overview)
    {
        ui->setupUi(this);
     
    QString fileName("D:/solar4000/QT/images/actual.png");
    if(QFile&#40;fileName&#41;.exists(&#41; == false&#41;
        QMessageBox::warning(this, "Application", "Wrong file name : " + fileName);
    else
     
        myButton.setIcon(QIcon(fileName));
     
    }
     
    Overview::~Overview()
    {
        delete ui;
    }
    

    @

    Thanks



  • Closed due to "double":/forums/viewthread/16237/ posting. Please stick to a single topic for a single question.


Log in to reply
 

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