Results 1 to 5 of 5

Thread: Common buttons on a stacked widget

  1. #1
    Join Date
    Aug 2011
    Posts
    42
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Common buttons on a stacked widget

    I have a Gui that has few layers/steps. Currently i'm using a stacked widget. When u press next it goes to the next widget. When u press back it goes back to the previous one. Can i make the 'next' & 'back' button common to all widgets ie. i dont want to make a separate 'next' & 'back' button for every single widget

    This is the code.
    v
    Qt Code:
    1. oid MainWindow::on_pb_back_clicked()
    2. {
    3. curr = this->ui->stackedWidget->currentIndex();
    4. this->ui->stackedWidget->setCurrentIndex(curr-1);
    5. }
    6.  
    7. void MainWindow::on_pb_next_clicked()
    8. {
    9. curr = this->ui->stackedWidget->currentIndex();
    10. this->ui->stackedWidget->setCurrentIndex(curr+1);
    11. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 20th September 2011 at 23:16.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Common buttons on a stacked widget

    Don't put those widgets on the QStackedWidget.

    BTW: Have you looked at QWizard?

  3. #3
    Join Date
    Aug 2011
    Posts
    42
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Common buttons on a stacked widget

    I tried to avoid stackedwidget, by stacking the labels/comboboxes on top of each other & showing/hiding them based on the 'begin/next'. But that slowed down the gui. So i started using stacked widgets. Qwizard mainly seems to used particularly for setup. I will try it if this doesnt work

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Common buttons on a stacked widget

    You have missed the point: put the Next and Previous buttons in the same container as the QStackedWidget. The QStackedWidget contains the pages of other widgets. Have a look at the attached Designer file
    Attached Files Attached Files

  5. The following user says thank you to ChrisW67 for this useful post:

    premroxx (21st September 2011)

  6. #5
    Join Date
    Nov 2013
    Posts
    6
    Thanks
    2

    Default Re: Common buttons on a stacked widget

    sorry to bring up the old thread, but when you are adding this
    Qt Code:
    1. void get_started::on_pushButton_clicked()
    2. {
    3. curr = this->ui->stackedWidget->currentIndex();
    4. this->ui->stackedWidget->setCurrentIndex(curr+1);
    5. }
    6.  
    7. void get_started::on_pushButton_2_clicked()
    8. {
    9. curr = this->ui->stackedWidget->currentIndex();
    10. this->ui->stackedWidget->setCurrentIndex(curr-1);
    11. }
    To copy to clipboard, switch view to plain text mode 

    *ps : I managed to get it working , sorry for this post
    Last edited by tomorrow; 15th November 2013 at 23:11.

Similar Threads

  1. problem in stacked widget
    By wagmare in forum Qt Programming
    Replies: 4
    Last Post: 24th February 2009, 08:28
  2. Stacked widget mouse propagation
    By bunjee in forum Qt Programming
    Replies: 3
    Last Post: 14th November 2008, 17:54
  3. Stacked Widget Scroll
    By csvivek in forum Qt Programming
    Replies: 6
    Last Post: 27th May 2008, 11:36
  4. Stacked Layout. & Widget.
    By csvivek in forum Qt Programming
    Replies: 1
    Last Post: 13th May 2008, 08:56
  5. Acces a stacked widget...?
    By ucomesdag in forum Qt Programming
    Replies: 5
    Last Post: 25th November 2006, 14:05

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.