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. QMainWindow and its children vs visibility at focus change/minimizing
Qt 6.11 is out! See what's new in the release blog

QMainWindow and its children vs visibility at focus change/minimizing

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.8k Views 2 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.
  • M Offline
    M Offline
    michelson
    wrote on last edited by
    #1

    Hello,

    I have a QMainWindow instance with bunch of QDialogs and QWidgets set as its childern. User may open them by clickin some actions on menubar. What is happening, that in fact I don't want to be happenin:

    • when I minimize main window its children are minimized as well (I guess because they are its children)
    • when I have some dialog/widget opened (visible) it stays ON TOP of the main window even if I click in the main windows area (focus thingy i guess)

    My question is:

    • is there a non-complicated solution to fix this behaviour? Idk.. like settings a flag? something like that, I cannot find anything in docs (at least so far)

    What I came across during searching:

    • 'orphaning' children :D (setting their parent to Q_NULLPTR) inside stateChanged event and turning it back again depending on the event type.
      I did not test/used it yet since out of curiosity I wanted to ask you guys about it? Do you think above solution is sensible enough to be used or are there any other better ones?

    Best Regards,
    M.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Have you tried simply not to give the dialogs a parent?

      MyDialog * dia= new MyDialog ();

      You will need to delete them your self when app is closing.

      1 Reply Last reply
      2
      • M Offline
        M Offline
        michelson
        wrote on last edited by
        #3

        Simplest solutions are the best - thank you!
        I kinda feel really dumb now :D
        Anyway - solved.

        mrjjM 1 Reply Last reply
        1
        • M michelson

          Simplest solutions are the best - thank you!
          I kinda feel really dumb now :D
          Anyway - solved.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @michelson
          Well often :)
          There was a thread not so long ago talking
          about how to delete the dialogs later.
          If you make them members, its pretty basic.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            michelson
            wrote on last edited by
            #5

            Can you point me to this thread (just in case - I may find something usefull there)?

            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