So I'm back asking for help with yet another problem I've got an inherited QTabWidget that has several pages. Each page contains a QWidget which holds a few other non-gui objects and a single QTextEdit as the only GUI object. I'm trying to keep it so that when a tab is removed and another tab is set as the current one, that new current tab's QTextEdit has keyboard focus. Right now with the code I have, when I delete a tab, the new one is correctly set, but the focus is on some unknown item.
The first time I press the tab key, the QTabBar gets focus, allowing me to press the arrow keys to select different tabs. The 2nd time that I press the tab key, the QTextEdit then has focus. I'm trying to get it so that when a tab closes, the next tab that becomes current shows up with the keyboard focus in its QTextEdit.
Any Ideas on what I'm doing wrong? Here's the main section of code where I'm setting the focus inside my QTabWidget member function ...or trying to
Paul
// Step 1: Select a new tab and set its console to have focus
//This is the index of the tab to recieve focus after the other one closes
int nextInLine = 0;
if (tabIndex != 0)
nextInLine = tabIndex-1; //tab to the left found
else if ( count() > 1) //There are at least 2 tabs before tab removal
nextInLine = 1; //tab to the right found
//else, we will be left with only one tab
this->setCurrentIndex(nextInLine); //Set new current tab
QWidget *pWidget
= ( widget
(nextInLine
));
if (pWidget)
this->setCurrentWidget( pWidget); //Move the focus to the tab's page (console)
//Step 2: Execute the old tab, right in the temple... it'll be quick
removeTab(tabIndex); //Removes the tab from the display
// Step 1: Select a new tab and set its console to have focus
//This is the index of the tab to recieve focus after the other one closes
int nextInLine = 0;
if (tabIndex != 0)
nextInLine = tabIndex-1; //tab to the left found
else if ( count() > 1) //There are at least 2 tabs before tab removal
nextInLine = 1; //tab to the right found
//else, we will be left with only one tab
this->setCurrentIndex(nextInLine); //Set new current tab
QWidget *pWidget = ( widget(nextInLine));
if (pWidget)
this->setCurrentWidget( pWidget); //Move the focus to the tab's page (console)
//Step 2: Execute the old tab, right in the temple... it'll be quick
removeTab(tabIndex); //Removes the tab from the display
To copy to clipboard, switch view to plain text mode
Bookmarks