no. focus methods are only for widgets which are currently visible. You are doing it in the right way.
no. focus methods are only for widgets which are currently visible. You are doing it in the right way.
Thanks Nish, but what about this 2 methods:
Qt Code:
previousInFocusChain (), nextInFocusChain ()To copy to clipboard, switch view to plain text mode
This 2 methods return Widget*. When I use them like this:
Qt Code:
ui->stackedWidget->setCurrentWidget(ui->stackedWidget->previousInFocusChain());To copy to clipboard, switch view to plain text mode
But I get the following Application Output:
QStackedWidget::setCurrentWidget: widget 0x3eb2d8 not contained in stack
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.
dont you see "focus" in these methods also? they all fall in the same criteria i mentioned you about.
use index instead of widgets. something like-This 2 methods return Widget*. When I use them like this:
Qt Code:
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.
Qt Code:
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
sattu (28th September 2011)
Thanks a lot Nish,
This INDEX stuff works a lot great. Thanks once again for the help.
With Regards,
Sattu.
Last edited by sattu; 28th September 2011 at 14:43.
Oops sorry, My mistake.Thanks Giving Statement modified
![]()
Bookmarks