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. QDialog modal issue
QtWS25 Last Chance

QDialog modal issue

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 6.6k 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.
  • H Offline
    H Offline
    HenningL
    wrote on 28 Sept 2011, 08:00 last edited by
    #1

    Hello,

    i have a problem getting my QDialogs modal.

    What happens is, that I show my QDialogs with exec() which should make them modal (tried using setModal and show() before either). It works... for QDialogs which I start from dialogs or widget within my QMainWindow. But I have to start some QDialog directly from QMainWindow, so their QActions to open them is directly on the QMainWindow.
    And here comes in a strange behaviour (at least from my perspective). When I open a QDialog from QMainWindow with exec() it is noch modal for the first time. Closing this and then opening the same or another QDialog, these dialogs are modal. So this only happens the first time.

    What may be the reason for this behaviour? Is there any event that has to be triggered before I can add the first QDialogs to my QMainWindow? Or something else? Unfortunately i can't post any code, so this will be a little guessing around and collecting ideas.

    The program runs on Linux.

    Regards
    Henning Lange

    1 Reply Last reply
    0
    • H Offline
      H Offline
      HenningL
      wrote on 28 Sept 2011, 09:27 last edited by
      #2

      I just realized that this has nothing to do with the first or second time.

      It is related to clicking into the QMainWindow before openen a QDialog.

      So it seems the QMainWindow has to be the active window before calling a QDialog.

      But how can i achieve this programmatically? I tried work-around with mainwindow.setFocus and sending a QMouseEvent to the MainWindow. Both doesn't work.

      Can someone give me an idea of how to simulate a mouse-click properly?

      This is how i try it right now, but it doesn't work:

      @ QPoint pos(1,1);
      QMouseEvent event(QEvent::MouseButtonPress, pos, Qt::LeftButton, 0, 0);
      app.sendEvent(&mainframe, &event);@

      Another thing i inspected: When i calll the dialog without clicking into the mainwindow first, then the dialog has all 3 buttons in the title bar. When i click into mainwindow first, then the dialog has only the close button.

      I hope someone can give me insight to this behaviour.

      Thanks in advance
      Henning Lange

      1 Reply Last reply
      0
      • H Offline
        H Offline
        HenningL
        wrote on 28 Sept 2011, 11:25 last edited by
        #3

        Okay... another reply.

        Investigating this problem further i found out the the call on
        @myMainWindow.showFullScreen();@
        is the problem. If I call
        @myMainWindow.showMaximized();@
        the problem does not occur so i guess this issue is related to the X-Window-System.

        Is here anybody who can assist me with this problem? It's pretty tough for me to solve this using showFullScreen().

        In hope for a helping hand
        Henning Lange

        1 Reply Last reply
        0
        • P Offline
          P Offline
          puksec
          wrote on 16 Nov 2011, 13:18 last edited by
          #4

          Hi, I had a similar problem, and i have solved it by calling show() instead of exec().
          Hope it helps you.

          mydialog.setModal(true);
          mydialog.show();

          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