Can't remove a tab from QTabWidget[SOLVED]



  • 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


  • Moderators

    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.



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


  • Moderators

    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.



  • 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


  • Moderators

    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.



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.