Important: Please read the Qt Code of Conduct -

Add a new widget in QGridLayout - Backgroud not displayed

  • Hi,

    I have a QWidget with a QGridLayout containing two others widget. When I dynamically add a new widget to the grid and want to show it, it shows the new widget but not its background. None of its parents widget have a background css style. How can I resolv this so my new background widget is shown ?

  • Lifetime Qt Champion


    What background should there be ?

  • an image set in the css with qt designerw. I have basically two designer class : News and Everwyhere Window, and the code below :

    GUI::EverywhereWindow::EverywhereWindow(QWidget *parent) :
    ui(new Ui::EverywhereWindow),

    GUI::News *news = new GUI::News(this);
    ui->gridLayout->addWidget(news, 2, 0);


  • Lifetime Qt Champion

    Are you sure the image is found at run time ?

Log in to reply