Pyqt5 help!!
Moved
Solved
Qt for Python
-
-
@Dexter99 You can create widgets (like labels) dynamically and show them:
void MainWindow::on_button_clicked() { QLabel *label = new QLabel(this, "Some text"); // Put your label into layout or position it manually label->show(); }
-
@JonB said in Pyqt5 help!!:
@jsulm
Not that it matters, but for the record do you have toshow()
it after adding? I could swear I add dynamic labels all the time without callingshow()
...If not added to a layout applied on a visible widget, then yes you have to call show.
-
@SGaist
Ah, yes, I do mean adding to already visible widget parent/layout, so that's why I don't need to.So, I'm not criticising @jsulm's code, but where he has added
new QLabel(this, "Some text");
thethis
is theQMainWindow
, which will be shown, so he didn't need to put in thelabel->show();
, right?