Results 1 to 20 of 20

Thread: How to hide all wizard buttons

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to hide all wizard buttons

    It's funny how some of us (and I am guilty as well) are so resistant to throwing out ineffective code that "sort of works but not really", when it is obvious (even while I am being resistant) that just biting the bullet and throwing it out would result in something that is so much cleaner and maintainable. Pack rat mentality, I suppose.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to hide all wizard buttons

    I never hestitate to throw away everything I've got and start from scratch. Unfortunately (at least for me) my workmates rarely share my point of view. How do you tell your boss that the thing you've been working on for the last two weeks should be trashed. And how do you explain you will just need two days to rewrite it? "So what have you been doing during those two weeks?"
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to hide all wizard buttons

    I perpetually make the mistake of working from the inside out, starting with data representation and algorithms, and then developing the GUI later. When the boss comes by and says, "Show me the program", and I say, "There isn't one yet", the reply is, "Well, then what have you been doing?" But if I do it from the outside in, I end up with so many wires dangling from the GUI that invariably some of them don't get hooked up. The boss is happy though - seeing the knobs and the blinking lights gives the impression that I'm actually working.

  4. #4
    Join Date
    Dec 2014
    Posts
    82
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to hide all wizard buttons

    Yes,

    Basically this is my main problem :P I don't have more time to change so I'll keep it that way because its fine for the boss(not for me because I don't like to have buttons with no function on them but...) and if I have to change it later, I'll see what I do.

    Y tried to put a stackwidget in mainwindow and throw mainwindow on main.cpp instead of wizard, and in this stackedwidget, put my first 3 wizardpages and it worked but not so fine... I threw my wizard like:
    Qt Code:
    1. //main.cpp
    2. MyWizard mw;
    3. mw.setFixedSize(800,700);
    4. mw.showMaximized();
    To copy to clipboard, switch view to plain text mode 

    The setfixedSize is for setting the developing window to the same as the final screen (it will go to a device with that resolution). So when I put it all in the stackedwidget in mainwindow and throw:

    Qt Code:
    1. //main.cpp
    2. MainWindow mm;
    3. mm.setFixedSize(800,700);
    4. mm.showMaximized();
    To copy to clipboard, switch view to plain text mode 

    Then the screen size is the fixed one but the widgets inside have another. The wizardpage1 for example have a VBoxLayout where I add all the items and it worked well on the wizard but it seems that it doesn't work with the stackedwidget so not having time to see what happens I'll let the Wizard structure for the moment.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to hide all wizard buttons

    Quote Originally Posted by roseicollis View Post
    Then the screen size is the fixed one but the widgets inside have another. The wizardpage1 for example have a VBoxLayout where I add all the items and it worked well on the wizard but it seems that it doesn't work with the stackedwidget so not having time to see what happens I'll let the Wizard structure for the moment.
    Most likely you didn't set a layout somewhere. And use QStackedWidget instead of QMainWindow, you don't need one.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    roseicollis (19th February 2015)

  7. #6
    Join Date
    Dec 2014
    Posts
    82
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to hide all wizard buttons

    Most likely you didn't set a layout somewhere. And use QStackedWidget instead of QMainWindow, you don't need one.
    Ok, I created a new Qt class on the project which is
    Qt Code:
    1. class StackedWidget : public QStackedWidget
    To copy to clipboard, switch view to plain text mode 
    and I copied the same code I had in Mainwindow to its constructor, so I have:

    Qt Code:
    1. StackedWidget::StackedWidget(QWidget *parent) :
    2. QStackedWidget(parent),
    3. ui(new Ui::StackedWidget)
    4. {
    5. ui->setupUi(this);
    6.  
    7. QWidget* centralWidget = new QWidget();
    8. QComboBox *m_pComboBox = new QComboBox();
    9.  
    10. addWidget(new WP1);
    11. addWidget(new QPushButton("Button 3"));
    12. addWidget(new QPushButton("Button 2"));
    13. setFixedSize(480,300);
    14.  
    15. m_pComboBox->addItem("Page 1");
    16. m_pComboBox->addItem("Page 2");
    17. m_pComboBox->addItem("Page 3");
    18.  
    19. QVBoxLayout *layout = new QVBoxLayout;
    20. layout->addWidget(m_pComboBox);
    21.  
    22. setWindowTitle("QStackedWidget Change CurrentIndex");
    23. centralWidget->setLayout(layout);
    24. setFixedSize(500,350);
    25.  
    26. connect(m_pComboBox,SIGNAL(activated(int)),this,SLOT(setCurrentIndex(int)));
    27. }
    To copy to clipboard, switch view to plain text mode 
    But it shows nothings more than an empty window

    And in main.cpp :

    Qt Code:
    1. StackedWidget st;
    2. st.setFixedSize(960,600);
    3. st.show();
    To copy to clipboard, switch view to plain text mode 

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to hide all wizard buttons

    What sense does it make to setup a UI file on a stacked widget? You are treating it like a common widget and not as a stacked widget. Stop blindly copying code in hope it will work
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. The following user says thank you to wysota for this useful post:

    roseicollis (19th February 2015)

  10. #8
    Join Date
    Dec 2014
    Posts
    82
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to hide all wizard buttons

    Ohhhhhhhhhh shit... forgot to comment that line... -.-''

    The line its created by Qt when I create the class and I always comment it, but this time I didn't see it... my fault... I was blind thinking about the layouts and didn't see that.

    Thank you!

    Edit: One more thing: In wp1 I have 2 buttons, do you know why do they appear at the bottom of the page and not at the top? I mean.. now is like if there were gravity and buttons go as down as they can while before, with QWizard they were as 'up' as they can.
    Last edited by roseicollis; 19th February 2015 at 11:52.

  11. #9
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to hide all wizard buttons

    The code you have written for your StackedWidget class makes no sense at all.

    A stacked widget is just an empty container for holding a collection of other widgets. The collection is like deck of cards, and only one card can be visible at a time. The code you wrote adds three cards to the deck: the first one of type WP1, the next two of type QPushButton.

    Then you do something weird with a combo box in a layout and you set that as a "central widget", whatever that is. Is it a new widget in the stack?

    If I can try to look inside your mind, it appears that what you might want to do is to have a combo box that lets you choose which widget in the stack you want to be visible. In that case, you don't want that combo box to be in the stack of widgets at all, you want it to be external to it.

    So if that's what you want, then create a new class, derived from plain old vanilla QWidget, add a QVBoxLayout to it, put the combobox on top and a plain old vanilla QStackedWidget in the bottom. In the constructor for this widget, fill in your combo box, create the widgets that will serve as the cards in your stack, and choose which one appears first.

    If you want to keep the design flexible, if you have widgets in the stack that need to control which page is shown next (click a button on page 1 that causes page 3 to be shown), then expose that click to the top level widget using a custom signal, and let the top level widget tell the stack which page to show next. If you push this logic down into the individual pages (as you appeared to have been doing), then you end up with a rat's nest of interdependent code.

    Signals and slots help you modularize things and make it so that the only widgets that need to know the details of what's going on are the ones in charge. All the little low-level widgets just do their thing and tell the guys in charge (via signals) that something has happened that they might want to pay attention to.

    Look a QPushButton - does it care what widget it is inside of? No. It's whole job is to display its label and icon and to let whoever cares know when someone has clicked it. Your page widgets should act the same way.

  12. The following user says thank you to d_stranz for this useful post:

    roseicollis (26th February 2015)

  13. #10
    Join Date
    Dec 2014
    Posts
    82
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to hide all wizard buttons

    Thanks d_stranz,

    That example was so clear

Similar Threads

  1. using wizard
    By arjita in forum Newbie
    Replies: 14
    Last Post: 28th July 2012, 18:48
  2. Replies: 1
    Last Post: 29th September 2011, 11:14
  3. To Wizard or Not ?
    By fassage in forum Qt Programming
    Replies: 1
    Last Post: 6th November 2009, 10:42
  4. Disabling Wizard Buttons in a QWizard
    By JimDaniel in forum Qt Programming
    Replies: 1
    Last Post: 30th October 2007, 17:53
  5. How to add a Wizard ?
    By npc in forum Qt Tools
    Replies: 4
    Last Post: 24th July 2007, 14:28

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.