0
votes

QtQuick.Window allows us to scope window behavior using the "flags" property with Qt::WindowFlags. From the Qt docs:

Window flags are a combination of a type (e.g. Qt::Dialog) and zero or more hints to the window system (e.g. Qt::FramelessWindowHint).

If the widget had type Qt::Widget or Qt::SubWindow and becomes a window (Qt::Window, Qt::Dialog, etc.), it is put at position (0, 0) on the desktop. If the widget is a window and becomes a Qt::Widget or Qt::SubWindow, it is put at position (0, 0) relative to its parent widget.

Examples exist of QML uses of Qt::WindowFlags.

Unfortunately, all the available examples create system windows in that the windows are visible to the system window manager. The docs claim that non-system windows can also be implemented using the Qt::SubWindow flag but I have not been able to achieve this. Does anyone have a working example in QML?

See QMdiSubWindow for examples of it working in C.

2
So you basically want a pseudo-window inside a system window?dtech
Yes. Could I implement this from scratch in QML? Also yes. But why spend the time if it's already supported? As an ancillary note I'd also like someone to show me that Qt::SubWindow actually works in QML.BrianTheLion
You can refer to this question. The easiest way could be to implement a "fake" inner window.BaCaRoZzo
Also this pretty much answer your question. No support. That's a little bit old but AFAIK there were no developments from this point of view.BaCaRoZzo
@BaCaRoZzo Thanks! I'd seen both of these but was still hoping for a little help from the framework with some of the basic logic like minimization, maximization, dragging, etc. Question: Will the QMdiArea option support multiple layers of nested windows? My guess is no.BrianTheLion

2 Answers

0
votes
import QtQuick 2.5
import QtQuick.Window 2.2

ApplicationWindow {
  id: main
  visible: true
  width: 1280
  height: 1024

  Window {
    visible: true
    flags: Qt.SubWindow
  }
}

For me this creates a secondary window that is always no top of the application window, is not visible as a regular window to the taskbar and task switch, and doesn't have minimize, maximize and close buttons, but it still has a frame and a name. However, it is not confined to the area of the application's main window, it can move outside of it, and it moves independently of the main window.

If that's the behavior you are after, then you are all set. If you want to have it confined to the main window and have it be moved together with it, just implement a simple qml Item with the necessary decoration and buttons, then you can put whatever content you want in it.

0
votes

A QMdiSubWindow is not actually a Window, but a widget behaving like a window inside a special parent window.

I assume for a moment you are using QtQuick as the UI technology with QML, in which case you can simply do this by having any type of Item as a child of the root element and with a higher Z value then any of the other children.

A common technique is to have one or more overlay layers

import QtQuick 2.0

Item {
    id: mainWindow

    // main window content that should be below the sub windows

    Item {
        id: mdiArea

        // any item in here is on top of any mainWindow contents
        // individual stacking order can easily be controlled with each item's "z" property
    }

    Item {
        id: popupArea
        // any item in here is on top of everything in mdiArea
    }
}

Instead of Item for the MdiArea one could consider to create a also emtpy custom item in C++, but which offers positional management for its children, e.g. "tile" or "stack".

A class like that could even make a nice contribution to Qt itself.