PDA

View Full Version : TabWidget index



beppuz
9th September 2011, 17:47
Hello,
I would like to know what the signal when I move between the tabs ....
Then if I create 5 tabs and I want to save into a variable my current position, i.e. the index of the tab in the foreground ... how do I? What is the method??

Thanks !!!!!!!

amleto
9th September 2011, 18:46
answered elsewhere (http://www.qtforum.org/article/36569/tabwidget-index.html)

Lykurg
9th September 2011, 20:02
For everyone who don't want to change the forum: QTabWidget::currentChanged().

amleto
9th September 2011, 21:44
actually currentIndex() is a better solution since it does the job for you already.

Lykurg
9th September 2011, 23:40
Actually QTabWidget::currentIndex() is a property whereas QTabWidget::currentChanged() is the signal which notifies you about a tab change. That is the main question. Furthermore have a look at the argument of QTabWidget::currentChanged() ... you don't have to call QTabWidget::currentIndex() at all.

amleto
9th September 2011, 23:47
Implicit in the question is the actual need - the current index. since there is no need to use signal to store the value to check it later, currentIndex is the correct approach - any time you want to know the index, just check it! No need for connecting signals/slots. no need for storing a value that is already stored in the tab widget!!!

Lykurg
10th September 2011, 00:41
I would like to know what the signal when I move between the tabs ....
Asked for a signal.

Then if I create 5 tabs and I want to save into a variable my current position, i.e. the index of the tab in the foreground ... how do I? What is the method?QList<int> is also a variable and could be used for some sort of history. But neither you nor me can tell what the better solution is since we don't know what beppuz really wants.

beppuz
10th September 2011, 11:51
Thanks for your answers ....
it works! thank you very much