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. Can't remove a tab from QTabWidget[SOLVED]
QtWS25 Last Chance

Can't remove a tab from QTabWidget[SOLVED]

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 2.1k 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.
  • K Offline
    K Offline
    karim24
    wrote on last edited by
    #1

    this code is inside a function "the fuction is a solt of a menu button"
    @int i=2;
    ui->tabWidget_3->removeTab(i);
    i++;
    //some code
    while(..){
    //...
    }@

    the thing is when i insert a break point at line 3
    and debug, when i pass line 2 which is removetab ,
    and get to line3 ,and even to the wile loop ,
    the tab 2 is not removed untill i get out of the function

    so is there a way to make it remove that tab
    at that line before exitting the fucntion
    or there is something that i'm missing about
    all this

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      how many tabs does your tabbar have?
      Please note that the tab index is 0-based. So if you remove the tab with index 2 the third tab is removed.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • K Offline
        K Offline
        karim24
        wrote on last edited by
        #3

        yes ,i know about the indexing ,the tab has 5 tabs

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          are you sure that at the time you call removeTab() the tab bar already has tabs? removeTab() removes the tab immediately.
          You may want to check the tab count before calling removeTab() with QTabWidget::count() and output it.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

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

            yes i just multidouble checked,
            with no breaking point it removes it "can't tell at which line",
            but with breaking point it removes it untill the return
            of the slot function i'm sure not at line 2

            1 Reply Last reply
            0
            • raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              whats the output of the following:
              @
              qDebug() << "count before:" << ui->tabWidget_3->count();
              int i=2;
              ui->tabWidget_3->removeTab(i);
              i++;
              qDebug() << "count after:" << ui->tabWidget_3->count();
              @

              I think you expect to see the tab to removed while your hold on the breakpoint in the debugger, am i right? This won't happen since you also hold on the event loop which paints the gui.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • K Offline
                K Offline
                karim24
                wrote on last edited by
                #7

                count before: 5
                count after: 4

                ah ok i get it now ,so it' s removing it but not repainting
                it yet,and yes, i was expecting to see the tab to removed
                while i hold on the breakpoint

                thanks a lot for keeping up with me

                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