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] Synchronizing tab ordering with button ordering
Forum Update on Monday, May 27th 2025

[SOLVED] Synchronizing tab ordering with button ordering

Scheduled Pinned Locked Moved General and Desktop
qtabwidgetqtabbarlayout
4 Posts 2 Posters 1.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.
  • J Offline
    J Offline
    Jakob
    wrote on 28 Aug 2015, 14:59 last edited by Jakob
    #1

    Dear readers,

    In my application I have some function that requires a whole bunch of parameters. There is a tabbed settings panel, that can be used to configure four 'presets'. Additionally there is a 'start' button for each of these four parameter configurations. These buttons are (currently) in a HBoxLayout.

    I'd like these buttons to follow the ordering of the tabs in the settings panel. I.e. if I move the second tab the first location, the second button should move in front inside the horizontal layout as well.

    Is anyone aware of existing code that already does it? Otherwise, how could I do this? (in particular I don't have a clue how to reorder the buttons in the horizontal layout, if at all possible)

    For bonus, I'd like to be able to update the layout of the buttons already while dragging the tab, so don't wait for the tabMoved signal before updating the button ordering.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 28 Aug 2015, 21:37 last edited by
      #2

      Hi,

      AFAIK there's nothing ready made for that. Without the bonus part you can simply take the button out and use insert to put it at the right place back in.

      Hope it helps

      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
      0
      • J Offline
        J Offline
        Jakob
        wrote on 31 Aug 2015, 09:28 last edited by
        #3

        Hej,

        Thanks for the reply. It confirmed my suspicions.

        What I didn't realize before however, is that the tabMoved signal is actually emitted independent on whether the mouse is still down or not. GREAT! I created a very simple prototype, and as it turns out, I get everything I want, including the bonus feature by simply connecting to QTabBar::tabMoved and in the slot writing a line along the lines of the following:

        m_view.buttonContainer->insertItem(to, m_view.buttonContainer->takeAt(from));
        

        Here m_view is an instance of the prototype widget I created, buttonContainer is a HBoxLayout that holds the same number of buttons as the tab bar.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 31 Aug 2015, 21:13 last edited by
          #4

          Great !

          Thanks for sharing your solution :)

          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
          0

          3/4

          31 Aug 2015, 09:28

          • Login

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