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. Qt 4.8.6 - Parent Window on Linux
Forum Updated to NodeBB v4.3 + New Features

Qt 4.8.6 - Parent Window on Linux

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.1k 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.
  • J Offline
    J Offline
    JoNo_21
    wrote on last edited by
    #1

    On Windows if I create 2 windows, with one being the parent of the other the child window becomes a floating window. Namely the child cannot go underneath the parent window. On my Linux box this behavior doesn't seem to work. My code is:

    @
    #include <QApplication>
    #include <QWidget>

    int main(int argc, char **argv)
    {
    QApplication app(argc, argv);

    QWidget widget;
    widget.setWindowTitle("win1");
    widget.show();
    
    QWidget widget2;
    widget2.setWindowTitle("win2");
    widget2.setParent(&widget, widget.windowFlags());
    widget2.show();
    

    }
    @

    Any suggestions?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      I guess it depends on a window manager.
      For example in Gnome3 a widget window from your example is always below widget2 window.
      But widget gets focus when mouse goes over it and I can put it above widget2 if I select "Always on Top" from a titlebar menu.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JoNo_21
        wrote on last edited by
        #3

        Ok, but is there a way to make windows on Linux behave in the same floating manor as on Windows?

        The closest I can see is to set the always on top flag for child windows, but that won't really work with children of children correctly.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DBoosalis
          wrote on last edited by
          #4

          Could always do something like this for the first window:

          Declare widget1 to have a member childWidget.virtual method for

          @ widget1.childWidget = &widget2;@

          And write out its virtual method for the focusInEvent() with something like:

          @void MainWindow::focusInEvent(QFocusEvent *)
          {
          if (childWidget)
          childWidget->raise();
          }
          @

          Can propigate the raise for all other children as well.

          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