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. [SOLVED] Adding QMenubar under every tab of QTabWidget
QtWS25 Last Chance

[SOLVED] Adding QMenubar under every tab of QTabWidget

Scheduled Pinned Locked Moved General and Desktop
qtabwidgetqmenubarpython
6 Posts 3 Posters 2.6k 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.
  • S Offline
    S Offline
    Streakflash
    wrote on 26 Aug 2015, 14:04 last edited by Streakflash
    #1

    Hi

    I'm trying to find a way to insert a custom menubar for every TAB of QTabWidget. I just could not find any satisfying soulution! Please help me to figure it out.

    Thank you

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 26 Aug 2015, 14:32 last edited by
      #2

      You can't really add a menu to a tab directly, but there's a workaround. The only assumption is that the content widget of the tab has a layout (no matter what type). Layouts have a setMenuBar() method so you can sneak the menu there like this:

      int numTabs = tabWidget()->count();
      for(int i = 0; i < numTabs; ++i)
         tabWidget->widget(i)->layout()->setMenuBar(yourMenuBar);
      
      1 Reply Last reply
      1
      • S Offline
        S Offline
        Streakflash
        wrote on 26 Aug 2015, 19:15 last edited by Streakflash
        #3

        @Chris-Kawa omg YES! You are AWESOME! i was cracking my head all day trying to find a solution... Thank you! but Is it possible to realize from QT Designer?

        M 1 Reply Last reply 26 Aug 2015, 19:35
        0
        • S Streakflash
          26 Aug 2015, 19:15

          @Chris-Kawa omg YES! You are AWESOME! i was cracking my head all day trying to find a solution... Thank you! but Is it possible to realize from QT Designer?

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 26 Aug 2015, 19:35 last edited by
          #4

          @Streakflash
          Yeah Chris rocks :)

          You cant do it in designer
          but you can do it in mainwin constructor after setupIU
          it would just be
          ui-> tabWidget->widget

          If you have added it "visually".

          S 1 Reply Last reply 26 Aug 2015, 19:37
          0
          • M mrjj
            26 Aug 2015, 19:35

            @Streakflash
            Yeah Chris rocks :)

            You cant do it in designer
            but you can do it in mainwin constructor after setupIU
            it would just be
            ui-> tabWidget->widget

            If you have added it "visually".

            S Offline
            S Offline
            Streakflash
            wrote on 26 Aug 2015, 19:37 last edited by
            #5

            @mrjj yeah thats how I'm doing right now, just wanted to know because controlling it from designer would be much comfortable :)

            M 1 Reply Last reply 26 Aug 2015, 19:38
            0
            • S Streakflash
              26 Aug 2015, 19:37

              @mrjj yeah thats how I'm doing right now, just wanted to know because controlling it from designer would be much comfortable :)

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 26 Aug 2015, 19:38 last edited by
              #6

              @Streakflash
              Yeah I agree. But a lot of stuff is not really possible from Designer. Sadly.

              1 Reply Last reply
              0

              4/6

              26 Aug 2015, 19:35

              • Login

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