Mike N.
Mike N.

Reputation: 358

Is it possible to reference individual tabs of a QTabWidget by tab number?

Very quick question here. I was wondering if it is possible for me to reference individual tabs from a QTabWidget by number. This will save me a lot of time, as I am generating an unknown number of tabs during run-time. I could not find anything in the QT documentation, but I feel like this is a very basic feature that should be included. I am thinking something like this (not real code just an idea, I realize tabNumber() doesn't exist):

 ui->tabArea->tabNumber(12);

If there isn't a public function, perhaps there's some other way? Please don't suggest referencing tabs by name because that is out of the question (potentially 100's of tabs), and I have already tried it.

Upvotes: 0

Views: 350

Answers (2)

Frank Osterfeld
Frank Osterfeld

Reputation: 25165

If you want the tab with a certain index, use widget():

 QWidget* tab = tabWidget->widget( index );

Upvotes: 2

thorsten müller
thorsten müller

Reputation: 5661

I think the setCurrentIndex() method is what you are looking for.

Upvotes: 0

Related Questions