views:

410

answers:

4

I'm making a simple Qt application. It has 4 screens/pages:

  1. Start import
  2. Select folder to import images to
  3. Accept or reject each image in folder, and when no images left:
  4. "No images left" and an OK button.

I can't figure out the best way to implement this. I started off with a QWidget, but this quickly got unmanageable.

Is a QWizard too constrained?

EDIT: Part of the problem with QWizard is it seems to always have "Back" and "Next" buttons. I don't want those as options in this program, so this leads me to believe that a wizard isn't exactly what I'm after.

+1  A: 

here (basic) and here are examples of QWizards.

You can make QWizardPages for your screens and add them to a QWizard. With registerField() you can register fields to communicate between pages.

EDIT: I didn't test this, but i guess you can control the button layout of QWizard with setButtonLayout

corné
+6  A: 

I think a QWizardPage is your best bet.

You can disable the 'back' on a QWizardPage by using setCommitPage(True) on it.

You'll also have to override nextId for the 'variable' amount of QWizardPages you want in between step 2 and 4.

ChristopheD
A: 

Create a dialog with a "Start Import" button on top. When the user clicks this:

Populate a QFormLayout :

The layout should have a checkbox and the label is the name of the picture to import. I'm not sure of your requirements, but you could also display a thumbnail of the image.

The user just checks the images he wants.

Then at the bottom have a "Save..." button. When the user clicks this, a Save As dialog appears. You save all the checked images, discard the others.

If there are no images, change the "Save..." button text to "OK", and display a QLabel with the "No images left" string. You can switch between the QLabel and QFormLayout using a QStackedWidget.

Checkout this article on QFormLayout: http://doc.trolltech.com/qq/qq25-formlayout.html

Option: Get rid of the "Start Import" button. Have the app automatically populate the QFormLayout on startup (possibly in constructor if its fast enough).

Mark Beckwith
+5  A: 

I'm going to disagree slightly on using a QWizard here. It would be fairly easy to do, but in this case I think it might be easier to just use a QStackedWidget and swap the widget shown based on what you want the user to be able to do. This is likely what is done inside QWizard anyway, without some of the complication for running the buttons and moving back and forth. You also might want to take a look at the state machine stuff they're looking at adding soon, since you're application could so easily be split into states.

Caleb Huitt - cjhuitt
I think this is more what I was thinking - I couldn't work out how the QWizard was doing it, but now I see!
Skilldrick