Question

Is it possible to save the current tab position/order in a QTabWidget in Qt?

What I want is basically to be able to let the users arrange the tabs as they like and then let them save the position so when they open the application again the tabs are where they were when last saved.

In the past I have done this put this only saves the window geometry.

QSettings mySettings("someName", "MyApp");
mySettings.beginGroup("MainWindow");
mySettings.setValue("geometry", saveGeometry());
mySettings.endGroup()

;

Any idea how or where can I find the information to get this done?

Thanks

Was it helpful?

Solution

Apparently there is no built-in way to do it, so you need to implement it. I don't see any possible troubles with it.

For example, you may obtain the index of each widget using QTabWidget::indexOf, or you may iterate over all tabs and obtain widgets using QTabWidget::widget, depending on which way is more convenient in your app.

When starting the app, sort your widgets by saved index and add them to the tab widget in that order.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top