Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How can i use Widget from Qt designer to add a QWidget inside of it from the code



  • alt text

    QWidget *widget = new QWidget();
    QGridLayout *layout = new QGridLayout(widget);
    widget->setLayout(layout);
    layout->addWidget(new QPushButton("My Button", widget));
    

    How can i add widget inside a Widget from qt designer


  • Lifetime Qt Champion

    Hi
    Any widget you add in the designer is accessible via
    ui->widgetname

    So if you place your code after setupUI in constructor then
    you can just use it like any normal pointer that you new'd yourself


Log in to reply