Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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

    Hi,

    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) :
    QWidget(parent),
    ui(new Ui::EverywhereWindow),
    _menuOpen(true)
    {
    ui->setupUi(this);

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

    }


  • Lifetime Qt Champion

    Are you sure the image is found at run time ?


Log in to reply