Unsolved Child window style
-
I have inherited a Qt application targeted for windows that someone else created a few years ago. I am not really Qt literate.
The application has several child windows within a main window. The issue is that the main window (and other dialogue windows) take on the windows 10 modern look, however child windows look like the old style windows XP style look with the curved corners to the title bar etc.
There is no style sheets etc. for these so its all bog standard stuff. Is there a way of making the child windows take on the same style as the main window?
At the moment the code to create a new child widow is basically this (there was also some signals and slots stuff which I haven't shown):
CWindow * pChild = new CWindow( this ); pChild->setAttribute( Qt::WA_DeleteOnClose ); ui->mdiArea->addSubWindow( pChild ); pChild->show(); pChild->raise();
-
If the child windows have a different look I guess that they don't use native window decoration but instead a titelBarWidget ist set somewhere in the code, which is styled in a XP like way.
Are those DockWidget windows? -
@QtNovice81
I think you should show how howclass CWindow
is declared (what is it derived from?), and any window styles it might set in constructor? -
I cant see anything about a titleBarWidget in the code or the .ui file.
CWindow is derived from QDialog and there is no styles set in the CWindow constructor.
Other windows in the application, that are not child windows, also derived from QDialog look fine. -
Hmm, a QDialog typically has a native title-bar that is generated by the OS and not your application, and the style cannot be changed from inside Qt. Could yo check if there is a Qt::FramelessWindowHint set to the dialog somewhere in the code, just to be sure?
-
@QtNovice81 said in Child window style:
CWindow is derived from QDialog and there is no styles set in the CWindow constructor.
I don't mean to throw you, as you've said you're not "Qt literate". However, note that
mdiArea->addSubWindow(pChild)
means these child windows are MDI subwindows.Now, I use these (though not under Windows), and they are not
QDialog
s, they areQWidget
s. I don't know whether having an MDI child window being dialog-styled is right/the cause, perhaps someone else might comment? Maybe this doesn't matter/is a red-herring, since this is MDI it is the MDI window furniture you may be talking about, and the widget type inside the subwindow is not relevant to your issue, not sure. -
Sorry its taken so long to reply....
There is no Qt::FramelessWindowHint set.
I have tried changing the windows so they inherit from QWidget instead of QDialog and the result is exactly the same.
The issue is definitely related to the line of code ..... mdiArea->addSubWindow(pChild) though. If I get another dialogue window in the application and add this line of code (e.g constraining the dialogue to inside the main window), that window is also affected.
Also I notice that these affected child windows/SubWindows have the QT icon on the titlebar and not the one used for the main application. Does this offer any clues as to whats happening here?
-
A mdi subwindow in Qt's winvista style (which is used under win10) is exactly "with the curved corners to the title bar".
So I don't think there's any "XP style look"... A mdi subwindow just looks like that.
It is not an actually window, but a child widget made by Qt, as well as the title bar, so it does not look like the main window. -
Thanks for the info Bonnie. Is there a workaround for it that you know of, i.e. can I make them look native?
-
@QtNovice81
No simple workaround AFAIK.
You can write your own style to make it look whatever you want.
But it is really very complicated and a lot of work to do.