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. Offsetting the tab in QTabWidget
QtWS25 Last Chance

Offsetting the tab in QTabWidget

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 4 Posters 5.2k 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.
  • P Offline
    P Offline
    Pauly
    wrote on last edited by
    #1

    I'm trying to use a QTabWidget to create a simple ribbon style bar.

    As creating the QTabWidget where the tabs are on the top, the tabs always start from the left, like this:
    alt text

    What should I do as I want to shift the tabs to the right, to get something like this:
    alt text

    As also how to add a button to the space created by the right-shift? Ultimately I'd like to get something similar to word, like this:
    alt text

    Thanks!

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

      Hi,

      Not a direct answer however, did you saw QTitanRibbon ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • P Offline
        P Offline
        Pauly
        wrote on last edited by
        #3

        Yes, I did. But I can't afford it... I just need something simple and I think I manage to implement all functional buttons etc, except having tab shifted and putting a main button there.

        1 Reply Last reply
        0
        • P Pauly

          I'm trying to use a QTabWidget to create a simple ribbon style bar.

          As creating the QTabWidget where the tabs are on the top, the tabs always start from the left, like this:
          alt text

          What should I do as I want to shift the tabs to the right, to get something like this:
          alt text

          As also how to add a button to the space created by the right-shift? Ultimately I'd like to get something similar to word, like this:
          alt text

          Thanks!

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

          @Pauly
          Hi for a "poor man's" version ;)
          you can use a stylesheet with

          QTabWidget::tab-bar {
          left: 50px; /* move to the right */
          }

          alt text

          It might be difficult to use in layout though as the round menu is half in over the tab
          but you might be able to tweak to work ok.

          1 Reply Last reply
          4
          • P Offline
            P Offline
            Pauly
            wrote on last edited by
            #5

            I still have to learn about stylesheet... So where do I set this? Thanks.

            QTabWidget::tab-bar {
            left: 50px; /* move to the right */
            }

            mrjjM 1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              myTabWidget->setStyleSheet("content of my cool style sheet");

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2
              • P Pauly

                I still have to learn about stylesheet... So where do I set this? Thanks.

                QTabWidget::tab-bar {
                left: 50px; /* move to the right */
                }

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

                @Pauly
                For start just use Creator
                Open a form UI file and place a tabwidget
                Then right click it and select Change Stylesheet.
                Its a mini editor.

                And then read
                http://doc.qt.io/qt-5/stylesheet-syntax.html

                1 Reply Last reply
                1
                • P Offline
                  P Offline
                  Pauly
                  wrote on last edited by
                  #8

                  Thanks a lot. I'm able to get something like this... poor man version...

                  alt text

                  I think some of the pushbutton at the top left corner is behind the title bar. How can I deal with this? Thanks!

                  mrjjM J.HilkJ 2 Replies Last reply
                  0
                  • P Pauly

                    Thanks a lot. I'm able to get something like this... poor man version...

                    alt text

                    I think some of the pushbutton at the top left corner is behind the title bar. How can I deal with this? Thanks!

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

                    @Pauly
                    Hi
                    Just set y of the button to zero
                    Seems to be minus currently.

                    1 Reply Last reply
                    0
                    • P Pauly

                      Thanks a lot. I'm able to get something like this... poor man version...

                      alt text

                      I think some of the pushbutton at the top left corner is behind the title bar. How can I deal with this? Thanks!

                      J.HilkJ Offline
                      J.HilkJ Offline
                      J.Hilk
                      Moderators
                      wrote on last edited by
                      #10

                      @Pauly

                      To raise the button over the other widgets, use

                      PushButton->raise();
                      

                      seems obvious, right.

                      ;-)


                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                      Q: What's that?
                      A: It's blue light.
                      Q: What does it do?
                      A: It turns blue.

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        Pauly
                        wrote on last edited by
                        #11

                        Yes, I made its y negative trying to have the button sit on top of the title bar, as the word scheme looks like. PushButton->raise(); does not raise it above the title bar. I read some post which said that title bar will always on top? Thanks...

                        mrjjM 1 Reply Last reply
                        0
                        • P Pauly

                          Yes, I made its y negative trying to have the button sit on top of the title bar, as the word scheme looks like. PushButton->raise(); does not raise it above the title bar. I read some post which said that title bar will always on top? Thanks...

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

                          @Pauly
                          The title bar is a so called decoration and is drawn by the OS/windows manager.
                          So the button can never be on top of it. ( also since its a child of mainwindow )

                          Also the button. is in a layout or anything else ?

                          1 Reply Last reply
                          0
                          • P Offline
                            P Offline
                            Pauly
                            wrote on last edited by
                            #13

                            After some researching, I hide the title bar by adding

                            setWindowFlags(Qt::Window | Qt::CustomizeWindowHint);
                            

                            Now I get:
                            alt text

                            Gone with the title bar is the drag&move, the minimize/maximize/close buttons. I guess I can add some widget for those function. Is there a Qt class that handle these kind of actions (title bar actions)? Thanks!

                            mrjjM 1 Reply Last reply
                            0
                            • P Pauly

                              After some researching, I hide the title bar by adding

                              setWindowFlags(Qt::Window | Qt::CustomizeWindowHint);
                              

                              Now I get:
                              alt text

                              Gone with the title bar is the drag&move, the minimize/maximize/close buttons. I guess I can add some widget for those function. Is there a Qt class that handle these kind of actions (title bar actions)? Thanks!

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

                              @Pauly
                              Hi
                              Sadly no, if you remove the decorations, you must re-implement all these features.
                              That said, if you ONLY need the min/max functions and not resize then its
                              just a few functions from QMainwindow to mimic those.

                              1 Reply Last reply
                              0
                              • P Offline
                                P Offline
                                Pauly
                                wrote on last edited by
                                #15

                                I tried it and it is more invloving to redo the title bar with a widget. The title bar response to upside resize and width change etc. I decide to defer it to later time. Maybe that is not a good idea for poor man. :)

                                mrjjM 1 Reply Last reply
                                0
                                • P Pauly

                                  I tried it and it is more invloving to redo the title bar with a widget. The title bar response to upside resize and width change etc. I decide to defer it to later time. Maybe that is not a good idea for poor man. :)

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

                                  @Pauly
                                  Nah for a fully functional version of a "word look" the amount of work would
                                  sort of disqualify it for a poors mans version. :)

                                  1 Reply Last reply
                                  0
                                  • P Offline
                                    P Offline
                                    Pauly
                                    wrote on last edited by
                                    #17

                                    Thanks a lot. :)

                                    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