Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Can't remove a tab from QTabWidget[SOLVED]

    General and Desktop
    2
    7
    1785
    Loading More Posts
    • 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
      karim24 last edited by

      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 Reply Quote 0
      • raven-worx
        raven-worx Moderators last edited by

        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 Reply Quote 0
        • K
          karim24 last edited by

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

          1 Reply Last reply Reply Quote 0
          • raven-worx
            raven-worx Moderators last edited by

            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 Reply Quote 0
            • K
              karim24 last edited by

              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 Reply Quote 0
              • raven-worx
                raven-worx Moderators last edited by

                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 Reply Quote 0
                • K
                  karim24 last edited by

                  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 Reply Quote 0
                  • First post
                    Last post