Problem in deleting QTabWidget's Widget...



  • HI All,
    I have added a QDialog into the QTabWidget...and while i try to remove first QWidget's TabBar...
    All TabBar is getting removed from my QTabWidget

    @
    void CTestDlg::addWidget()
    {
    CQuestionDlg *questionDlg = new CQuestionDlg();
    ui->tabExams->addTab( questionDlg , "Question1");
    }

    void CTestDlg::tabClose(int nCurIndex)
    {
    QWidget *wdgt = ui->tabWidget->widget( nCurIndex );
    if( wdgt )
    {
    delete wdgt;
    wdgt = 0;
    }
    ui->tabWidget->removeTab( nCurIndex );

    }
    @

    please let me know whether i am doing anything wrong on this..



  • You should call removeTab first

    @
    QWidget *wdgt = ui->tabWidget->widget( nCurIndex );
    ui->tabWidget->removeTab( nCurIndex );
    if( wdgt )
    delete wdgt;
    @

    wdgt = 0; Not needed because wdgt is local.



  • Thanks Vass ..its working fine....
    Thanks for your Valuable inputs..


Log in to reply
 

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