How to create a linear GUI program
I am making a simple Qt application. It has 4 screens / pages:
- Start import
- Select a folder to import images into
- Accept or reject each image in the folder, and when there are no images left:
- "No images left" and the "OK" button.
I cannot find a better way to implement this. I started with QWidget, but it quickly became unmanageable.
Is QWizard Too Limited?
EDIT: Part of the problem with QWizard seems to always have Back and Next buttons. I don't want them to be parameters in this program, so it makes me think that the wizard is not exactly what I want.
a source to share
I am slightly disagreeing on usage QWizard
here. It would be pretty easy to do, but in this case I think it would be easier to just use QStackedWidget
and exchange the displayed widget based on what you want the user to be able to do. This is probably the way it is done internally QWizard
, without any complications for triggering buttons and moving back and forth. You might also want to take a look at the government stuff they are looking for to add soon, as the application can be easily split into states.
a source to share
here's the (basic) and here's the QWizards examples.
You can make QWizardPages for your screens and add them to the QWizard. With registerField (), you can register fields for communication between pages.
EDIT: I haven't tested this, but I am guessing that you can control the layout of the QWizard's buttons using setButtonLayout
a source to share
Create a dialog with the Start Import button at the top. When the user clicks on this:
Customize QFormLayout
:
The layout should have a checkbox and the label should be the name of the imported image. I'm not sure about your requirements, but you can display a thumbnail image as well.
The user just checks the images they want.
Then at the bottom click the "Save ..." button. When the user clicks on this, the Save As dialog box appears. You keep all checked images, discard the rest.
If there are no images, change the text of the "Save ..." button to "OK" and display QLabel
with the line "No images left". You can switch between QLabel
and QFormLayout
with QStackedWidget
.
Check out this article at QFormLayout
: http://doc.trolltech.com/qq/qq25-formlayout.html
Option: get rid of the "Start import" button. Have your application auto-populate the QFormLayout on startup (perhaps in the constructor if it's fast enough).
a source to share