PDA

View Full Version : Overriding methods for QWizardPage(s) created in Qt Designer and accessing widgets.



astodolski
24th October 2012, 15:44
Hello,

I have not seen any examples that illustrate use of custom classes to override methods in QWizardPage class. All wizard examples I've seen are written outside of the designer. For instance, in Qt Creator I create a Wizard with two pages. All the widgets are contained in the ui file and I need access to each of the page's widgets as well as the methods i.e. initializePage(), nextId() etc. in both pages. The new project creation wizard creates an application with one class and the ui file. How do I override the two mentioned methods? In the header file created by the project wizard in Qt Creator, I have the following default header file:



#include <QWizard>
#include <QtCore>
#include "Interface.h"

namespace Ui
{
class FlashWizard;
class IntroPage;
}

class FlashWizard : public QWizard
{
Q_OBJECT

public:
explicit FlashWizard(QWidget *parent = 0);
virtual ~FlashWizard();

private:
Ui::FlashWizard* ui;
QString SupportFile;
QString iniFile;
QSettings* settings;
ushort Language_Id;
bool convertedOK;


};

class IntroPage : public QWizardPage
{
Q_OBJECT

public:

IntroPage(QWidget *parent = 0);

void initializePage();
int nextId() const;


};

#endif // FLASHWIZARD_H


I try and implement the method initializePage() as:



void IntroPage::initializePage()
{
setSubTitle(tr("Blah-Bah"));
}


That code is never executed. I can only access widgets from the main class - FlashWizard and get/set properties from the ui object, created in the main class. I am required to create UI objects in the designer and access them in code as per projects requirements. I am stuck as how to do that.

I hope that is clear, Thanks in advance

Lesiok
24th October 2012, 17:13
In Qt Designer promote one QWizardPage to IntroPage

astodolski
24th October 2012, 19:50
That sounds like you're suggesting adding a page and promoting it to IntroPage? Is that correct?


Dzięki

Added after 5 minutes:


In Qt Designer promote one QWizardPage to IntroPage


I get errors:

d:\flashwizard\ui_flashwizard.h:38: error: C2327: 'Ui_FlashWizard::IntroPage' : is not a type name, static, or enumerator
d:\flashwizard\ui_flashwizard.h:82: error: C2061: syntax error : identifier 'IntroPage'

Lesiok
25th October 2012, 12:02
Yes, we use this method on a daily basis. Errors can result from improperly specified header file with the definition of the class IntroPage.

astodolski
25th October 2012, 18:29
Please explain in a little more detail. There are no real methods detailing promoting a QWizardPage to an existing class.