how to remove tab with closable button.
so i have a QTabWidget and i want the tabs to be removable via the provided close button for each tab. how do i set it up so that 1) they will close when i click it and 2) i can delete what they where storing becuase i dynamically allocated there page widgits.
Re: how to remove tab with closable button.
Next time, please at least take a look at the docs before asking a question.
Re: how to remove tab with closable button.
i looked this time just didn't find it, i think i can remember to look 20min after you told me to in another thread :)
Re: how to remove tab with closable button.
So next time browse the docs two times before asking a question :rolleyes:
Re: how to remove tab with closable button.
i still dont understand how implement these functions to work, how do i add checks for things to the "event loop" exactly?
would i use a function like this?
Code:
if(obj==this) {
for(unsigned int i=0;i<Tabs->size();++i) {
if(tabCloseRequested(i)) {
delete Tabs->widget(i)->deleteLater();
Tabs->removeTab(i);
}
}
}
}
Re: how to remove tab with closable button.
Quote:
Originally Posted by
ishkabible
i still dont understand how implement these functions to work,
The signal tells you which tab requested to be closed. Connect a slot to it and remove the tab in question.
Quote:
how do i add checks for things to the "event loop" exactly?
What checks and what things?
Re: how to remove tab with closable button.
ok i'm pretty confused, i thought that i had to add a function to check for a signal to emitted in the event to the event loop, i am guessing this is done with slots but i don't know how to use slots. i use the QObject::connect function to connect a signal and a slot right?, could you explain how this is done and what two objects should be connected for this to be acomplised?
Re: how to remove tab with closable button.
Quote:
Originally Posted by
ishkabible
i use the QObject::connect function to connect a signal and a slot right?
Yes.
Quote:
could you explain how this is done and what two objects should be connected for this to be acomplised?
You have to create your own slot compatible with the signal I gave you and connect() the two. The slot will receive the index of the tab that wishes to be closed and you will just have to remove and delete it.
If that's still not clear enough (and even if it is) you should read about signals and slots in the docs.