PDA

View Full Version : TabWidget Problem



TJSonic
20th October 2010, 15:56
So, i create tabs with close button.

Connected close signal with close slot


connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));

and here is the close slot:


void MainWindow::closeTab(int idx1)
{
tabWidget->removeTab(idx1);

}

http://allsonic.com.ua/uploads/posts/2010-10/1287586522_tab1.jpg

if i trying to close the second tab im reciving

http://allsonic.com.ua/uploads/posts/2010-10/1287586484_tab2.jpg

so
if im trying to close the last tab, it works normally but if i close the second, all tabs after it are deleting too. What i do wrong??

tbscope
20th October 2010, 19:48
I can not reproduce that with the code you have given.

marcvanriet
20th October 2010, 21:40
Hi,

Seems similar to the problem in the following thread : Removing-a-tab-in-QTabWidget-removes-tabs-to-right-as-well (http://www.qtcentre.org/threads/35202-Removing-a-tab-in-QTabWidget-removes-tabs-to-right-as-well)

Regards,
Marc

TJSonic
21st October 2010, 14:25
Thanks. After reading that topic i decided that the best way to delete a tab is delete it in such way:



void MainWindow::closeTab(int idx1)
{
tabWidget->widget(idx1)->deleteLater();
}