how i can call func for dynamic created QWidget from MainWindow
-
hey guys, pls help me
Im have QWidget class Section
and button for add Section:void MainWindow::on_button_AddZone_clicked() { new_zone_name="Place #"; QString name=new_zone_name+QString::number(++ui::Section::zone_count); section = new ui::Section(name,300, ui->centralWidget); ui->centralWidget->layout()->addWidget(section); auto* anyLayout = new QVBoxLayout(); anyLayout->addWidget(new QLabel("Some Text in Section", section)); anyLayout->addWidget(new QTableView(section)); section->setContentLayout(*anyLayout); }
and Section have some function
public slots: void toggle(bool collapsed);
how i can call this func for ALL created by button QWidget from MainWindwow?
how i can call this func for definetely QWidget? (I can use some ID and etc???)Thank you!
-
hey guys, pls help me
Im have QWidget class Section
and button for add Section:void MainWindow::on_button_AddZone_clicked() { new_zone_name="Place #"; QString name=new_zone_name+QString::number(++ui::Section::zone_count); section = new ui::Section(name,300, ui->centralWidget); ui->centralWidget->layout()->addWidget(section); auto* anyLayout = new QVBoxLayout(); anyLayout->addWidget(new QLabel("Some Text in Section", section)); anyLayout->addWidget(new QTableView(section)); section->setContentLayout(*anyLayout); }
and Section have some function
public slots: void toggle(bool collapsed);
how i can call this func for ALL created by button QWidget from MainWindwow?
how i can call this func for definetely QWidget? (I can use some ID and etc???)Thank you!
@rexha52 said in how i can call func for dynamic created QWidget from MainWindow:
how i can call this func for ALL created by button QWidget from MainWindwow?
If you mean call it once at creation time you can call a
public slot
directly:section->toggle(true);
. If you mean in response to later signal doconnect()
as @mpergand says.how i can call this func for definetely QWidget? (I can use some ID and etc???)
I cannot understand this sentence.
-
@rexha52 said in how i can call func for dynamic created QWidget from MainWindow:
how i can call this func for ALL created by button QWidget from MainWindwow?
If you mean call it once at creation time you can call a
public slot
directly:section->toggle(true);
. If you mean in response to later signal doconnect()
as @mpergand says.how i can call this func for definetely QWidget? (I can use some ID and etc???)
I cannot understand this sentence.
@JonB https://recordit.co/Lo7FO1VnA9
when im click ADD BUTTON it create a widget from class Section. Every Section have some other widget(table, button, lavel etc)
when im created 5 Sections, how i can read some values or call some function from a certain Section, for example for QLabel in second Section? or in last created Section? -
@JonB https://recordit.co/Lo7FO1VnA9
when im click ADD BUTTON it create a widget from class Section. Every Section have some other widget(table, button, lavel etc)
when im created 5 Sections, how i can read some values or call some function from a certain Section, for example for QLabel in second Section? or in last created Section?@rexha52 said in how i can call func for dynamic created QWidget from MainWindow:
when im created 5 Sections, how i can read some values or call some function from a certain Section
Please show how you're creating those Section instances
-
@JonB https://recordit.co/Lo7FO1VnA9
when im click ADD BUTTON it create a widget from class Section. Every Section have some other widget(table, button, lavel etc)
when im created 5 Sections, how i can read some values or call some function from a certain Section, for example for QLabel in second Section? or in last created Section?