
Originally Posted by
sattu
Thanks Nish, but what about this 2 methods:
previousInFocusChain (), nextInFocusChain ()
previousInFocusChain (), nextInFocusChain ()
To copy to clipboard, switch view to plain text mode
dont you see "focus" in these methods also? they all fall in the same criteria i mentioned you about.
This 2 methods return Widget*. When I use them like this:
ui->stackedWidget->setCurrentWidget(ui->stackedWidget->previousInFocusChain());
ui->stackedWidget->setCurrentWidget(ui->stackedWidget->previousInFocusChain());
To copy to clipboard, switch view to plain text mode
But I get the following Application Output:
My main purpose is that I need a more general way of achieving this type of operations, instead of hard-coating the WidgetNames. Please help.
use index instead of widgets. something like-
void setPreviousWidget()
{
int index = stackWidget->currentIndex() - 1;
if ( index < 0 )
index = stackWidget->count() - 1;//go to last widget (or do not change if you like, return from here).
statckWidget->setCurrentIndex(index);
}
void setPreviousWidget()
{
int index = stackWidget->currentIndex() - 1;
if ( index < 0 )
index = stackWidget->count() - 1;//go to last widget (or do not change if you like, return from here).
statckWidget->setCurrentIndex(index);
}
To copy to clipboard, switch view to plain text mode
Bookmarks