Search code examples
c++qtqtabwidget

Is there a method or a way to check whether a user has visited a certain tab page on a QTabWidget?


I have a QTabWidget on my application, so user can navigate through the tab pages by clicking on the title, I want to know when user open a tab page, whether he/she visited this page previously. In QWizard class there is a method hasVisitedPage() which does the exact same thing on a wizard, but I couldn't find a similar method in QTabWidget class. What I want to know is, whether there is a method to do this like in QWizard?

this is the similar method in QWizard class http://doc.qt.io/archives/qt-4.8/qwizard.html#hasVisitedPage

Currently I am using a QList to store the visited page indexes and each time when a user open a tabpage check whether QList contains the index of the opened page, I think it would be more easy if I had a method to check


Solution

  • What I want to know is, whether there is a method to do this like in QWizard?

    Unfortunatelly, there is not.

    Currently I am using a QList to store the visited page indexes and each time when a user open a tabpage check whether QList contains the index of the opened page

    QWizard does the same, i.e. has a QList<int> history; attribute. So, in my opinion you are doing it the right way.

    Take a look at the source code for more details. In particular, QWizardPrivate::switchToPage might be interesting to you, in order to give you an idea how it is done in QWizard, so you can check your own implementation against that and adapt it if necessary.