PDA

View Full Version : Query about animation in QTabBar/QTabWidget



montylee
20th November 2009, 08:41
I have a QTabWidget with tabs which are created and removed dynamically depending upon what option user selects (see attached image tabs.jpg). Now, whenever a new tab is added, an animation needs to be shown. Here are the animation details:

When a new tab is added, the text of the previous tab disappears and the new tab slides out from left to right. After that the previous tab only contains the image without any text (see attached tabs1.jpg). The newly created tab will have image as well as text.

Now, the thing i need help with is the slide part of the tab. Rest everything has no animation.
Is it possible to do it in Qt4.3 or Qt4.4? I think there's some classes like QTimeLine, QGraphicsItemAnimation etc. Also, what's Qt Animation framework (http://qt.nokia.com/products/appdev/add-on-products/catalog/4/Utilities/qtanimationframework)? Is it like a separate package i have to download and build? Do i need this framework to do the above mentioned animation or can i just use the current animation classes in Qt?

wysota
20th November 2009, 09:00
It's possible but not with QTabWidget. You'd have to create your own tab bar, probably based on Graphics View. Then doing animations is very simple.

montylee
20th November 2009, 09:19
It's possible but not with QTabWidget. You'd have to create your own tab bar, probably based on Graphics View. Then doing animations is very simple.
Thanks for the quick reply!
So, i have to create my own QTabBar class derived from QTabBar and attach to the QTabWidget. Can you give some more details about this or point me to some examples? I haven't used Graphics View yet so don't know much about it. Should i check the examples given inside graphicsview folder of Qt? Also, for this partioular animation, i'll first need to remove the text from the current tab and then change the rect or x,y co-ordinates of the new tab to make it slide from left to right.

wysota
20th November 2009, 09:29
Thanks for the quick reply!
So, i have to create my own QTabBar class derived from QTabBar and attach to the QTabWidget.
No. You have to create your own tab bar and connect it to QStackedWidget.

montylee
20th November 2009, 09:51
No. You have to create your own tab bar and connect it to QStackedWidget.
But for this i'll have to make lot of changes in my application as my application uses lot of QTabWidget APIs. Can't i create my own custom tab bar and attach it to QTabwidget using setTabBar()? Why do i need to use QStackedWidget for this?

wysota
20th November 2009, 12:27
But for this i'll have to make lot of changes in my application as my application uses lot of QTabWidget APIs.
So don't use animations and you won't have to change anything.


Can't i create my own custom tab bar and attach it to QTabwidget using setTabBar()?
Sure you can, but you have to reimplement the whole QTabBar class to provide a wrapper around QGraphicsView.


Why do i need to use QStackedWidget for this?

I suggest you read about graphics view first. Then some things should become clearer.

montylee
20th November 2009, 13:03
okie...let me read about it first and i'll get back, thanks for your help :)