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

Editing qlabel text after show dialog



  • I have a code
    @void Eng::show(int type,Words* w)
    {
    exec();
    ui->label1->setText("example text");
    //...
    }@

    But it doesn't work, but if i write

    @@void Eng::show(int type,Words* w)
    {
    ui->label1->setText("example text");
    exec();
    //...
    }@@

    All edits correctly, but i need to edit text after showing.


  • Lifetime Qt Champion

    Hi,

    exec will "block" until you close the dialog.

    So what would you like to achieve ?


  • Moderators

    exec() is a blocking call that waits for your dialog to close. So a call to setText after that does have an effect, it's just that the dialog is no longer visible.
    To edit the label you need to do it while the exec is still executing, either in any events of your dialog or via a signal/slot connection triggered by some action.


Log in to reply