Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Open Dialog and emit signal
Forum Updated to NodeBB v4.3 + New Features

Open Dialog and emit signal

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qatto
    wrote on last edited by
    #1

    Hello,

    I am trying to open a dialog and emit a signal immediately so that some code can be executed within MainWindow while the dialog is open. Please advise on how it can be done.
    @void MainWindow::open_dialog()
    {
    Ui::Dialog ap;
    QDialog *diag = new QDialog;
    ap.setupUi(diag);
    diag->setModal(true);

    connect(this, SIGNAL(the_signal()), this, SLOT(edit_text()));
    
    while(diag->exec())
    {
        emit the_signal();
    }
    

    }@

    Web/Desktop Developer

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Hi,
      If you want the MainWindow to react on something that happens in the Dialog the Dialog itself must issue the signal.
      the diag->exec() will hold "execution" active there until the exec function is terminated by a user action (if there are ok/cancel or x button pressed).
      Or if the MainWindow should emit the signal before the execution of the dialog.
      greetz

      Greetz, Jeroen

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        Qatto
        wrote on last edited by
        #3

        The signal in this case has to be emitted by MainWindow. So you are probably saying this isn't possible

        Web/Desktop Developer

        1 Reply Last reply
        0
        • JeroentjehomeJ Offline
          JeroentjehomeJ Offline
          Jeroentjehome
          wrote on last edited by
          #4

          Everything is possible ;-)
          What you could try is to first emit the signal (after creation of QDialog) and then run the exec on the dialog. The exec will start the eventhandler on the dialog. Don't think this will work btw.
          On the other hand, you could start a single timer (e.g. 100msec) in the MainWindow just before the exec on the dialog.
          In the timerEvent of Mainwindow emit the signal you need in the dialog.
          That should work without a problem if you ask me.
          But why do you need this option anyway? Sounds a bit dodgy in object orientated programming.

          Greetz, Jeroen

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            Qatto
            wrote on last edited by
            #5

            I need the option so as to have a dialog displaying a progressBar that shows progress for a function inside MainWindow without interference (the dialog blocks interaction). But I have now opted to disable all widgets and have the progressBar inside MainWindow itself.

            Thanks Jeroentje@home for the help

            Web/Desktop Developer

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved