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. Converting a qframe to a qdialog - missing exec() - How to block until a window is closed
QtWS25 Last Chance

Converting a qframe to a qdialog - missing exec() - How to block until a window is closed

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.2k Views
  • 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.
  • P Offline
    P Offline
    psteranka
    wrote on last edited by
    #1

    I ran into a problem whereby I created a class that derived from QFrame and later realized I should have subclassed the QDialog class. I worked around this by just creating a new QDialog-based form, and copy/pasted the QFrame GUI items to the newly created QDialog *.ui form.

    If I wanted to stay with a QFrame, I would need to block until the frame window was closed. After the "window" (QFrame) is closed I then want to call methods get pull the data from the object.

    (Q) How can I block until a QFrame is closed? I looked for exec() or something like "wait" but didn't find it.

    Is there a way to simulate the QDialog::exec() function on a QFrame-based form?

    Thanks,
    PatS

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      It sounds like you're creating a dialog so I would suggest to use the right tools for the job and stick with QDialog. It has more than just exec() compared to QFrame. Its frame is styled properly. It closes on "esc" pressed. It has accept() and reject() methods and more.

      About every time I've seen a custom dialog created the right base was QDialog, but if you really wanted to re-invent the wheel you could just create a method called exec() and use "QEventLoop::exec":http://doc.qt.io/qt-5/qeventloop.html inside to start a local event loop and connect its quit() slot to whatever exit apparatus you design for your widget e.g. closing it.

      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