I’m writing QWizard based class. I need to init next page after next button clicked. When I add just first page, next button is disabled, so thats why I add Blank next page. And need catch next button press event and initialize next Page before it appears. I need your help to do that.
1) Enable next button when no next page.
2) And/Or generate/reinitialize next page after next pressed
Here is what I’ve got:
class GroupWizard : public QWizard { Q_OBJECT
//--------------------------------------------------------------------------------------------------
public: GroupWizard(QWidget *parent = NULL);
public: ~GroupWizard();
//--------------------------------------------------------------------------------------------------
private: void initWizard();
//--------------------------------------------------------------------------------------------------
public slots: void next();
//--------------------------------------------------------------------------------------------------
};
//--------------------------------------------------------------------------------------------------
GroupWizard::GroupWizard(QWidget *parent /*= NULL*/) : QWizard(parent, Qt::WindowTitleHint) {
initWizard();
setOptions(QWizard::NoBackButtonOnStartPage|QWizard::HaveFinishButtonOnEarlyPages);
}
//--------------------------------------------------------------------------------------------------
GroupWizard::~GroupWizard() {
}
//--------------------------------------------------------------------------------------------------
void GroupWizard::initWizard() {
const Zone & rootZone = GET_ZONE_MANAGER().getRootZone();
QHashIterator<QString, Zone*> iter(rootZone.getChildren());
QList<Zone *> zoneList;
while(iter.hasNext()) {
iter.next();
zoneList.append(iter.value());
}
addPage(new GroupWizardPage(zoneList));
/*addPage(new GroupWizardPage(zoneList));*/
}
//--------------------------------------------------------------------------------------------------
void GroupWizard::next() {
if (currentPage() == NULL)
return;
GroupWizardPage * curPage = (GroupWizardPage *)currentPage();
QList<int> zoneIds = curPage->getCheckedZonesIds();
QHash<int, Zone *> zonesHash = GET_ZONE_MANAGER().getZones();
QList<Zone *> zoneList;
for (int i = 0; i < zoneIds.count(); i++) {
Zone * zone = zonesHash.value(zoneIds.at(i));
if (zone)
zoneList.append(zone);
}
if (page(nextId()) == NULL)
return;
GroupWizardPage * nextPage = (GroupWizardPage *)page(nextId());
nextPage->initPage(zoneList);
QWizard::next();
}
//--------------------------------------------------------------------------------------------------
The problem is: I didn’t get into my next() slot.
↧