Results 1 to 2 of 2

Thread: A Question about stackedwidget

  1. #1
    Join Date
    Jan 2008
    Posts
    91
    Thanks
    8

    Default A Question about stackedwidget

    Hi All,
    I have a question about stacked widget.I have created a widget with Qt designer and I added it on stacked widget.But I wonder how can i check which page is opened on stacked widget.May be my explanation is not enough i added some codes here please look at it.

    This part i decleared zemin and i add to stackedwidget.
    cpp code
    Qt Code:
    1. zemin=new cEkrani;
    2. zemin->loadMod(false);
    3. ui.stackedWidget->addWidget(zemin);
    4. ui.stackedWidget->setCurrentWidget(zemin);
    To copy to clipboard, switch view to plain text mode 
    This part i want to check is zemin page opened or not but i couldn't do this
    Qt Code:
    1. if(ui.stackedWidget->currentWidget()==zemin)
    2. {
    3. ....
    4. .....
    5. }
    To copy to clipboard, switch view to plain text mode 

    How can i do this control with the name of widget?

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: A Question about stackedwidget

    You can use indexOf and currentIndex
    http://doc.trolltech.com/4.3/qstacke...t.html#indexOf

    Example in pseudocode:

    Qt Code:
    1. if(stackedwidget.indexOf(myWidget) == stackedwidget.currentIndex())
    2. {
    3. ...
    4. }
    To copy to clipboard, switch view to plain text mode 

    By the way: your method should work too.

    The documentation isn't really clear about this, but it says that the widgets need to have the stackedwidget as parent. Only looking at the documentation I'm not sure that using addWidget makes the widget a child of the stackedWidget.

    I guess it might not hurt to also do:
    zemin=new cEkrani(ui.stackedWidget);
    Last edited by jpn; 29th March 2008 at 16:31. Reason: missing [code] tags

  3. The following user says thank you to tbscope for this useful post:

    anafor2004 (29th March 2008)

Similar Threads

  1. Exceptions / setjmp/longjmp question
    By Aceman2000 in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2008, 17:14
  2. Does a StackedWidget plugin need multipage?
    By jayw710 in forum Qt Tools
    Replies: 2
    Last Post: 4th July 2007, 11:07
  3. Access to QSqlTableModel::isDirty Question.
    By patrik08 in forum Qt Programming
    Replies: 3
    Last Post: 12th April 2007, 17:49
  4. Question regarding how to paint after zoom.
    By JonathanForQT4 in forum Qt Programming
    Replies: 2
    Last Post: 26th January 2007, 15:34

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.