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. how to change the color of title bar in mdi window
Forum Updated to NodeBB v4.3 + New Features

how to change the color of title bar in mdi window

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 3.1k Views 2 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.
  • johnson54J Offline
    johnson54J Offline
    johnson54
    wrote on last edited by
    #1

    when mdi subwindow is added to mdiArea, how can I change its title bar color? thanks

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      You can a bit via stylesheet but it loses icon.
      QMdiSubWindow { border: 1px solid #00ff00; background: #ff00ff }
      QMdiSubWindow:title { background: #00ff00 }

      johnson54J 1 Reply Last reply
      2
      • mrjjM mrjj

        Hi
        You can a bit via stylesheet but it loses icon.
        QMdiSubWindow { border: 1px solid #00ff00; background: #ff00ff }
        QMdiSubWindow:title { background: #00ff00 }

        johnson54J Offline
        johnson54J Offline
        johnson54
        wrote on last edited by
        #3

        @mrjj it works, thank you. and how can I add the lost icons

        mrjjM 1 Reply Last reply
        0
        • johnson54J johnson54

          @mrjj it works, thank you. and how can I add the lost icons

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @johnson54
          I dont think you can with stylesheets. seems to be no tag for it.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            Kogotoro
            wrote on last edited by
            #5

            main.cpp

            #include <QStyleFactory>
            ...
            QApplication a(argc, argv);
            a.setStyle(QStyleFactory::create("Fusion"));
            ...
            

            or only for mdiwin

            QMdiSubWindow *subwin=ui->mdiArea->addSubWindow(mywidget);
            subwin->setAttribute(Qt::WA_DeleteOnClose);
            subwin->setStyle(QStyleFactory::create("Fusion"));
            

            style.css

            ...
            QMdiSubWindow{
            selection-background-color: grey;/*for some styles it also used as title bar main gradient color...*/
            padding: 4px;/*need for resize window with mouse*/
            border-color: lightgray;
            background: black;
            }
            ...
            
            IPlayGenji6I 1 Reply Last reply
            2
            • K Kogotoro

              main.cpp

              #include <QStyleFactory>
              ...
              QApplication a(argc, argv);
              a.setStyle(QStyleFactory::create("Fusion"));
              ...
              

              or only for mdiwin

              QMdiSubWindow *subwin=ui->mdiArea->addSubWindow(mywidget);
              subwin->setAttribute(Qt::WA_DeleteOnClose);
              subwin->setStyle(QStyleFactory::create("Fusion"));
              

              style.css

              ...
              QMdiSubWindow{
              selection-background-color: grey;/*for some styles it also used as title bar main gradient color...*/
              padding: 4px;/*need for resize window with mouse*/
              border-color: lightgray;
              background: black;
              }
              ...
              
              IPlayGenji6I Offline
              IPlayGenji6I Offline
              IPlayGenji6
              wrote on last edited by
              #6

              I don't know why

              QMdiSubWindow:title {
              background-color: green;
              }
              

              removes the icon.

              But this works perfectly.
              @Kogotoro said in how to change the color of title bar in mdi window:

              QMdiSubWindow{
              selection-background-color: grey;/*for some styles it also used as title bar main gradient color...*/
              }
              
              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