PDA

View Full Version : problem in stacked widget



wagmare
24th February 2009, 05:02
hi friends,
=> i am having two graphicsScene having several buttons in different nature ..
=> i add the two scene to a stackedWidget on different pages .. as parent .
=> now if i click any of the item in graphicsScene 1 the index of stacked widget has
to change ...
=>how can i communicate this from child to parent ... as if i click an item the index of the
page should change ..
/*mainwindow*/
include "panel.h" //graphic scene

QstackedWidget *stackWid = new QstackedWidget();
GraphicScene *panel1 = new GraphicsScene();
GraphicScene *panel2 = new GraphicsScene();

adding panel 1 and panel2 -->stackedWidget()

please help :)

aamer4yu
24th February 2009, 07:31
You can emit a signal on mouse press from scene.
Connect this signal with some slot and change index of stack widget.

jryannel
24th February 2009, 07:35
I need to guess a little bit. As I understand it an item in the graphics scene shall trigger a switch on the tab of the tab widget. And this item is contained in a graphics view itself is a page in the tab widget.

In general the item is not a object so it can't send signals. The scene could if you would derive from the scene. You could then hook about your custom signal to change to a particular tab.
Also your customscene could expose own objects, for example the tabwidget.

The scene is accessible from you graphics item (need to cast to your custom scene q_objectcast). Then you need to override you key or mouse events, access the logic and emit the signal. Which will not work, as you can only emit signals from within you class, where you declare the signal. Means you need a helper method in the scene (for example notifyTabChange(int index)) which will for you emit the signal.

Or if you have exposed the tabwidget in the scene, easily call the setCurrentIndex(int) function.

Hmmm, longer than I expected. Hope this helps.
- Juergen

wagmare
24th February 2009, 08:24
thanks aamer ...
yeah correct ... i will emit the signal from graphics item and i will connect to my stack widget slot ..
right ...

wagmare
24th February 2009, 08:28
I
In general the item is not a object so it can't send signals. The scene could if you would derive from the scene. You could then hook about your custom signal to change to a particular tab.
- Juergen

why? u can emit signal from a item (private)... see padnavigator example ... they are emitting a private signal from the item ...