PDA

View Full Version : QTabWidget problem



hnfmr
25th February 2011, 13:47
Hi all,

I have a tab with 3 pages. When I switch tab page, I have the QTabWidget::currentChanged(int) signal, however, this signal is emitted after the page is switched....

Is there any way to capture this signal before it switches tab?

Thank you

high_flyer
25th February 2011, 13:59
This sounds like you are on a wrong design path.
If you explain what it is you want to achieve and why, we might help you to solve it correctly.

hnfmr
25th February 2011, 14:56
This sounds like you are on a wrong design path.
If you explain what it is you want to achieve and why, we might help you to solve it correctly.

Yes, thank you. I will try to explain it a bit more clearly.

I have 3 tab pages. When I switch from one to the other. I need to check if widgets on one page have been modified, if they are, when I switch tab, I will ask the user if they want to discard or save them. If I use the QTabWidget::currentChanged(int), I will go to the other tab directly, without me being able to properly get user response...(discard or save)...

At the moment I'm trying to subclass QTabWidget such that I can get the internal QTabBar (since it's protected). But then again, QTabBar also only has currentChanged(int) signal...I'm having difficulties subclassing QTabBar and install custom signals.................Thanks

high_flyer
25th February 2011, 15:04
If I use the QTabWidget::currentChanged(int), I will go to the other tab directly, without me being able to properly get user response...(discard or save)...
Why not?
the user will not see the difference if the message box comes on just as the new tab got shown or when the old tab is still there (or, the difference has no effect on the user).
The user has to interact with the message box any how, not with the tab.

hnfmr
25th February 2011, 15:10
Why not?
the user will not see the difference if the message box comes on just as the new tab got shown or when the old tab is still there (or, the difference has no effect on the user).
The user has to interact with the message box any how, not with the tab.

Yes many thanks on your input.

I could also cache a variable recording current tab...and this issue can be fixed..

However, I am trying a way that does not cache states, and my UI was designed in Qt Creator...(I could also bypass this problem by hard-coding UI components).....
Thanks all the ways