[Interest] QWindow::setTransientParent fails on windows

Roland Winklmeier roland.m.winklmeier at gmail.com
Fri Sep 27 10:50:47 CEST 2013


Hi Tony,

thanks for your answer.

I'm giving you a little more background:
I have an application which offers the possibility to enhance it via
plugins/addons. I'm developing such an addon which also has its own window.
I of course want to have my application to be the child of the main
application, because otherwise it looks ugly and also the sound output of
the main application stops as soon as it looses focus.

I tried what you said, but I still have some points which are not met with
this approach. I have the requirements:
- if the main application has focus, the child window is always in front
- only one entry in the tab bar (this is fulfilled)
- if I minimize the main application, my child window should be minimized
as well

In the mean time I found some other weird stuff. I did some tests with QML
windows:

ApplicationWindow {
    id: mainWindow
    title: "My MainWindow"
    width: 640
    height: 480

    Button {
        text: "Child"
        onClicked: childWindow.visible = !childWindow.visible
    }

    Window {
        id: childWindow
        visible: true
    }
}

childWindow should have the parent mainWindow from the beginning. But it
isnt. I have to manually set the visibility to false and open it via the
button or close and open it with the button. Doing this will change it to
act like a proper child window. I guess this is a bug in Qt.

 setTransientParent still doesn't do anything at all. Maybe both issues are
related, I don't know.


2013/9/26 Tony Rietwyk <tony at rightsoft.com.au>

> Hi Roland, ****
>
> ** **
>
> I'm not sure what you are trying to achieve,  but I had a similar problem
> with the splash screen appearing with its own task bar tab.   I worked
> around the problem by doing:****
>
> ** **
>
>       int exstyle = GetWindowLong( mpSplash->winId(), GWL_EXSTYLE );****
>
>       SetWindowLong( mpSplash->winId(), GWL_EXSTYLE, ****
>
>             exstyle & ~WS_EX_TOOLWINDOW );****
>
> ** **
>
> before showing the splash.  ****
>
> ** **
>
> Hope that helps, ****
>
> ** **
>
> Tony****
>
> ** **
>
> ** **
>
> *From:* interest-bounces+tony=rightsoft.com.au at qt-project.org [mailto:
> interest-bounces+tony=rightsoft.com.au at qt-project.org] *On Behalf Of *Roland
> Winklmeier
> *Sent:* Thursday, 26 September 2013 2:34 AM
> *To:* interest at qt-project.org
> *Subject:* [Interest] QWindow::setTransientParent fails on windows****
>
> ** **
>
> Hi there,
>
> I'm currently struggling with QWindow::setTransientParent on a windows
> platform. I have two different windows and want to set one as the child of
> the other. Using QWindow::setParent() was not successful, because it was
> embedded into the parent (I got the parent QWindow* by calling fromWinID() )
>
> If I call QWindow::setTransientParent(parent), nothing changes. I have two
> different entries in the taskbar instead of one and both windows are still
> parentless.
> After looking into the code in the windows platform plugin, I found out
> that the following method is called in qwindowswindow.cpp:
>
> void QWindowsWindow::updateTransientParent() const.
>
> This method sets the parent by setting GWL_HWNDPARENT. But MSDN explicitly
> said, you should NOT do it this way:
>
> "You must not call SetWindowLong with the GWL_HWNDPARENT index to change
> the parent of a child window. Instead, use the SetParent function. "
> Source:
> http://msdn.microsoft.com/en-us/library/windows/desktop/ms633591%28v=vs.85%29.aspx
> ****
>
> So I assume this should be changed in the windows platform plugin to be a
> real parent? Are there any other options to set the parent without
> embedding it?****
>
> Cheers****
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130927/d5b30e0c/attachment.html>


More information about the Interest mailing list