I am trying to add a new QPushButton to a QWidget, but it doesn't seem to have an addWiget
method.
I am using the following code:
QWidget *wdg = new QWidget;
QPushButton *btn=new QPushButton(this);
btn->setText("text");
wdg->addWidget(btn)
wdg->show();
hide();
the 6th line is giving an error
CodePudding user response:
You can pass QWidget as parent to QPushButton.
QWidget *wdg = new QWidget;
QPushButton *btn=new QPushButton(wdg);