Results 1 to 5 of 5

Thread: problem in stacked widget

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default problem in stacked widget

    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

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in stacked widget

    You can emit a signal on mouse press from scene.
    Connect this signal with some slot and change index of stack widget.

  3. #3
    Join Date
    Sep 2008
    Location
    Munich
    Posts
    32
    Thanked 8 Times in 6 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: problem in stacked widget

    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

  4. #4
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in stacked widget

    thanks aamer ...
    yeah correct ... i will emit the signal from graphics item and i will connect to my stack widget slot ..
    right ...

  5. #5
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in stacked widget

    Quote Originally Posted by jryannel View Post
    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 ...

Similar Threads

  1. Problem building application with custom widget
    By Uthar in forum Installation and Deployment
    Replies: 6
    Last Post: 19th January 2009, 17:57
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. Widget resizing problem
    By fwohlfert in forum Qt Programming
    Replies: 3
    Last Post: 23rd February 2006, 08:16
  4. [Qt 4.1.0] Split a widget on demand
    By Townk in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 14:16
  5. Replies: 7
    Last Post: 3rd February 2006, 10:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.