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. Child window style
Forum Updated to NodeBB v4.3 + New Features

Child window style

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 4 Posters 1.3k Views
  • 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.
  • Q Offline
    Q Offline
    QtNovice81
    wrote on last edited by
    #1

    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();
    
    JonBJ 1 Reply Last reply
    0
    • gde23G Offline
      gde23G Offline
      gde23
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0
      • Q QtNovice81

        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();
        
        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @QtNovice81
        I think you should show how how class CWindow is declared (what is it derived from?), and any window styles it might set in constructor?

        Q 1 Reply Last reply
        0
        • JonBJ JonB

          @QtNovice81
          I think you should show how how class CWindow is declared (what is it derived from?), and any window styles it might set in constructor?

          Q Offline
          Q Offline
          QtNovice81
          wrote on last edited by
          #4

          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.

          JonBJ 1 Reply Last reply
          0
          • gde23G Offline
            gde23G Offline
            gde23
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0
            • Q QtNovice81

              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.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @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 QDialogs, they are QWidgets. 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.

              1 Reply Last reply
              0
              • Q Offline
                Q Offline
                QtNovice81
                wrote on last edited by
                #7

                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?

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  Bonnie
                  wrote on last edited by Bonnie
                  #8

                  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.

                  1 Reply Last reply
                  1
                  • Q Offline
                    Q Offline
                    QtNovice81
                    wrote on last edited by
                    #9

                    Thanks for the info Bonnie. Is there a workaround for it that you know of, i.e. can I make them look native?

                    B 1 Reply Last reply
                    0
                    • Q QtNovice81

                      Thanks for the info Bonnie. Is there a workaround for it that you know of, i.e. can I make them look native?

                      B Offline
                      B Offline
                      Bonnie
                      wrote on last edited by Bonnie
                      #10

                      @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.

                      1 Reply Last reply
                      1

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved