PDA

View Full Version : how to overlap widgets



herculis
2nd September 2014, 17:42
I need to overlap two qvideowidget in same lyout how can i do it plz could anyone help me in this

wysota
3rd September 2014, 08:18
Implement your own layout that will do that. However that's (I mean overlapping widgets) probably not the proper approach to solve your real problem, whatever it might be.

herculis
3rd September 2014, 09:41
''Implement your own layout that will do that.''
i didnt get it.Can u explain it lil bit more

Radek
3rd September 2014, 09:58
Use QStackedWidget class. The QStackedWidget is a "notebook" but without "bookmarks". Changing a page in QStackedWidget is made otherwise (using setCurrentIndex(), which is a slot, but like any other slot, which can be called directly).

wysota
3rd September 2014, 10:10
i didnt get it.Can u explain it lil bit more

Subclass QLayout and implement virtual functions that will position the widgets the way you want.

However, again, that will probably not solve your real problem which is the goal of overlapping widgets. Overlapping widgets is usually a bad idea and there are other ways to achieve similar results. Choosing the right approach depends on the task that needs to be solved.

http://www.catb.org/esr/faqs/smart-questions.html#goal

herculis
4th September 2014, 09:38
I want to show a video on let say on display1 after some time will hide the display1 and then display2 will show the remaining video.
So i need widget tobe overlap.

wysota
4th September 2014, 12:01
So i need widget tobe overlap.

No, you don't. You can e.g. use QGraphicsView with two QGraphicsVideoItem instances and fade (or whatever you want) those. Even if you choose to go with widgets, you don't need any layout for overlapping them, just place them in a common parent and make sure their geometry covers the geometry of the parent.

herculis
4th September 2014, 13:18
Thanks wysota.
Actually i am new to Qt and C++ so can you plz give me one short exmaple of this parent and child concept.

wysota
4th September 2014, 13:28
This is the most basic thing about Qt. See docs on Object Trees & Ownership

herculis
4th September 2014, 13:52
ok thanks
and How can i hide or fade one widget and show other.

wysota
4th September 2014, 15:07
By calling hide() and show() respectively.

herculis
4th September 2014, 15:26
So if i use hide and show the problem is it takes a few mili seconds to hide and show other and therefore there is a gap very small but it exist i dont want that gap how can i remove gap

wysota
4th September 2014, 16:15
With widgets you will always have a small gap. That's why I suggested to use QGraphicsView. Then you can easily manipulate opacity of each item to provide a fluent transition.

herculis
4th September 2014, 17:27
I tried to make the qwidget tranparent as i m using qstackwidget class and i did the upper widget transparent but i cannot see the lower widget its just a black screen can u help me in this

and regarding qgraphicview how can i make it transparent.

wysota
5th September 2014, 06:51
Please have a look at API exposed for graphics items, you will surely find a relevant method. I even mentioned it a couple of posts back. I don't want to repeat myself over and over again.

herculis
8th September 2014, 14:37
Hi wysota,
I used qgraphicvideoitem ,overlap them with setsize and make one of the item transparent but then also there is somemili sec gap to make it transpaent and show other video item

wysota
8th September 2014, 14:54
How are you switching the items? Show your code please.

herculis
8th September 2014, 15:07
screen=qgraphicvideoitem();
screen1->setOpacity(0);

with this command I am making it transparent.

wysota
8th September 2014, 15:23
screen=qgraphicvideoitem();
screen1->setOpacity(0);

with this command I am making it transparent.

That's not enough to help you. Please show complete code which demonstrates how the whole process looks like.