PDA

View Full Version : event when closing a tab



fearu
22nd September 2010, 22:43
Hi,

I'm new to qt, and I have to make a small program to apply filters to photos and it must have a GUI. I have little skills with any GUI framework, so I choosed QT Creator to make the project.

I'm trying to make the program with tabs to open more than one image. I have in the ui form an empty tabWidget, and I fill it in the code like this:

QLabel *imageLabel = new QLabel;
ui->tabWidget->addTab(imageLabel, QString("foo"));

So my problem here is how can I make a slot/event or whatever it is called so when I clic on x button on the tab it calls the code where I destroy the image, the label, etc.

The tabs/labels get created dinamically when I open an image, I need a way to destroy the contents of any tab where the user cliced x.

If I didn't explain it correctly please ask for a better explanation and I'll try, I don't have great English skills.

ChrisW67
23rd September 2010, 05:00
QTabWidget::tabCloseRequested() seems to be the obvious signal to connect to a slot. Your tab removal and cleanup code should be in that slot.

fearu
23rd September 2010, 12:08
Thanks, that is exactly what I needed.