Nominate our 2022 Qt Champions!

How can I put image in background of MainWindow.ui

  • Hi,
    good morning

    I am using Qt 5.0.2.

    I Created New Qt GUI Application and I choosed class Information as per below.

    Class name : MainWindow
    Base class : QMainWindow
    Header file : mainwindow.h
    source file : mainwindow.cpp
    Gernerate form : tick
    Form file : mainwindow.ui

    I want to put Image in Background of MainWindow, for that purpose I have check in
    standard Widget Box but I can't get any Widget for that.

    So, please let us know how can I put image in background of MainWindow ui.

    Plesae help.


  • Hi Dharmendra ,
    For your problem I think you can create a widget and set an Icon to it using QWidget::setIcon()
    and then pass a pointer to that widget to QMainWindow::setCentralWidget(* QWidget)

Log in to reply