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. Avoid that a QDialog activates with show()
Forum Updated to NodeBB v4.3 + New Features

Avoid that a QDialog activates with show()

Scheduled Pinned Locked Moved Solved General and Desktop
qdialog
5 Posts 3 Posters 2.5k 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.
  • F Offline
    F Offline
    floatingWoods
    wrote on last edited by
    #1

    Hello,
    I have an application that is a main window, which can have several QDialogs as children (always in front). When I create and show such a child QDialog, it activates (i.e. it gets the mouse and keyboard focus/input, which is normal). However, I would prefer to have the QDialog not activate, since I still need the keyboard focus on the main window.
    So what I am currently doing is:

    childDialog->show();
    mainWindow->activateWindow();
    

    But I feel this is not the correct way of doing. Is there a way to show a QDialog without having it activated automatically?
    Thanks for any information

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

      There's an attribute for that. Somewhere before showing the dialog call setAttribute(Qt::WA_ShowWithoutActivating) on it.

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

        An option could be to add the Qt::WindowDoesNotAcceptFocus flags attributs of your dialog,
        if your dialog doesn't have any line or text edit.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          floatingWoods
          wrote on last edited by
          #3

          Thanks for the quick reply. My Dialogs have actually those line widgets, etc. They are more like contextual tool window, that pop open if a certain object is selected in the main window. The User will very probably continue to work in the main window, but if he/she clicks on the child dialog, he/she can change the selected object's properties.

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

            There's an attribute for that. Somewhere before showing the dialog call setAttribute(Qt::WA_ShowWithoutActivating) on it.

            1 Reply Last reply
            2
            • F Offline
              F Offline
              floatingWoods
              wrote on last edited by
              #5

              That's just perfect! How could I oversee this?
              Thanks a lot!

              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