I was able to add a new tab using qtabwidget->addTab ( newtab, title );
But is it possible to focus on this tab in my code?
Thanks
Focus Mode in Chrome Make sure you run Google Chrome Canary and that the browser is up to date. Load chrome://flags/#focus-mode. Set the flag to Enabled. Restart Google Chrome.
The keyboard shortcut Cmd + Shift + A (Mac) or Alt + Shift + A (Windows) is the easiest way to switch between tabs in Chrome. This shortcut pulls up a sidebar of your recent tabs.
'setCurrentWidget' or 'setCurrentIndex' will do the job.
You can use either the pointer to the added widget or a numeric index.
See:
http://doc.qt.io/qt-5/qtabwidget.html#setCurrentWidget
http://doc.qt.io/qt-5/qtabwidget.html#currentIndex-prop
For example, if you have a tab widget with say 3 tabs, you can focus on the 2nd tab like this:
ui->tabWidget->setCurrentIndex(1);
If you just want to use the pointer to your widget (MyWidget of type QWidget) then here is another example:
MyWidget* pointerToMyWidgetInTab = new MyWidget();
ui->tabWidget->addTab(pointerToMyWidgetInTab,"Tab2")
ui->tabWidget->setCurrentWidget(pointerToMyWidgetInTab2);
Count the total number of tabs and set the last one:
ui->tabWidget->setCurrentIndex(ui->tabWidget->count()-1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With