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. Add widgets in distinct tabs
Qt 6.11 is out! See what's new in the release blog

Add widgets in distinct tabs

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 2.1k Views 1 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.
  • M Offline
    M Offline
    mohamaddanesh44
    wrote on last edited by
    #1

    i have some widgets and a QTabWidget with 3tabs.
    how can i add a specific widget to a specific tab (not all the tabs)?

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

      Hi,

      Do you mean add a new widget to the widget in a given tab ?

      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
      • M Offline
        M Offline
        mohamaddanesh44
        wrote on last edited by
        #3

        no no, i already have some widgets ( e.g. widget1, widget2, widget3) and some tabs (e.g. tab1,tab2,tab3) .
        i want widget1 to add to tab1,
        widget2 to tab2,
        widget3 to tabs3.

        what i could did was add widget1 to tab1,tab2,tab3.

        how can i add widget1 to only tab1?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          angelicaP
          wrote on last edited by
          #4

          if you post some code, maybe somebody will be able to look through and give you a hint.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            Buckets
            wrote on last edited by
            #5

            You can do it a couple of ways.
            If you have already created widgets that you want to display as a their own tab, then
            @
            QTabWidget *tab_widget;
            QWidget *tab_one;
            QWidget tab_two;
            tab_widget = new QTabWidget;
            tab_one = new QWidget();
            tab_two = new QWidget();
            /

            do stuff to tab_one and tab_two
            */
            tab_widget->addTab(tab_one,"One");
            tab_widget->addTab(tab_two,"Two");
            @
            If you already have tabs (tab1, tab2, ..., tabn) you can use those as parents for your widgets
            @
            QLabel hi_label("hi", tab1);
            @

            Hopefully this helps

            ba ba ba
            ba na na na

            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