IntruderApril 19, 2020, 3:36 p.m.
Не могу разобраться с QWizard и QWizardPage
Всем доброго времени суток!
Помогите разобраться с этим двумя классами. Вроде делаю все по примеру из Help, но ничего не получается, а именно кнопка перехода далее не становится активной, хотя страницы добавляются.
Выкладываю текст своего Wizard (его первый вариант):
Текст заголовочного файла индексов страниц wizard
#ifndef SHARED_DEFS_H #define SHARED_DEFS_H enum { INTRO_PAGE, PARTNUMBER_PAGE, ALTIDENT_PAGE, CONNECTOR_PAGE_1, CONNECTOR_PAGE_2, REFERNCES_PAGE, FINAL_PAGE }; #endif // SHARED_DEFS_H
- Создаю два страницы QWizardPage
#ifndef INTROPAGE_H #define INTROPAGE_H #include <QWizardPage> enum standardPart { CONNECTOR, DISTRIBUTION_PART, ACCESSORY, SOLDER_SLEEVE, SHRINK_SLEEVE, IDENTIFICATION_SLEEVE, CONDUIT, WIRE_MATERIAL }; class QRadioButton; class QLabel; class IntroPage: public QWizardPage { Q_OBJECT public: IntroPage( QWidget* parent = nullptr ); // ~IntroPage(){} int nextId() const override; void initializePage() override; private: QLabel* m_standardpart; QLabel* m_select_lbl; QRadioButton* m_connector_rbtn; QRadioButton* m_distriburionpart_rbtn; QRadioButton* m_accessoty_rbtn; QRadioButton* m_soldersleeve_rbtn; QRadioButton* m_shrinksleeve_rbtn; QRadioButton* m_identificationsleeve_rbtn; QRadioButton* m_conduit_rbtn; QRadioButton* m_wirematerial_rbtn; }; #endif // INTROPAGE_H
#include "intropage.h" #include <QRadioButton> #include <QLabel> #include <QBoxLayout> #include "shared_defs.h" IntroPage::IntroPage( QWidget* parent ) : QWizardPage( parent ) { setObjectName("introPage"); setTitle(tr("Main page")); setSubTitle(tr("Electrical standard part with the subordinated item.")); QBoxLayout* mainLayout = new QVBoxLayout; mainLayout->addWidget(m_standardpart = new QLabel); mainLayout->addWidget(m_select_lbl = new QLabel); mainLayout->addWidget(m_connector_rbtn = new QRadioButton(tr("Connector"))); mainLayout->addWidget(m_distriburionpart_rbtn = new QRadioButton(tr("Distribution part"))); mainLayout->addWidget(m_accessoty_rbtn = new QRadioButton(tr("Accessory"))); mainLayout->addWidget(m_soldersleeve_rbtn = new QRadioButton(tr("Solder sleeve"))); mainLayout->addWidget(m_shrinksleeve_rbtn = new QRadioButton(tr("Shrink sleeve"))); mainLayout->addWidget(m_identificationsleeve_rbtn = new QRadioButton(tr("Identification sleeve"))); mainLayout->addWidget(m_conduit_rbtn = new QRadioButton(tr("Conduit"))); mainLayout->addWidget(m_wirematerial_rbtn = new QRadioButton(tr("Wire material"))); mainLayout->addStretch(1); m_standardpart->setVisible(false); registerField( "typeStandardpart*", m_standardpart); m_connector_rbtn->setChecked( true ); setLayout( mainLayout ); } int IntroPage::nextId() const { return PARTNUMBER_PAGE; } void IntroPage::initializePage() { if(m_connector_rbtn->isChecked()){ m_standardpart->setNum(standardPart::CONNECTOR); }else if(m_distriburionpart_rbtn->isChecked()){ m_standardpart->setNum(standardPart::DISTRIBUTION_PART); }else if(m_accessoty_rbtn->isChecked()){ m_standardpart->setNum(standardPart::ACCESSORY); }else if(m_soldersleeve_rbtn->isChecked()){ m_standardpart->setNum(standardPart::SOLDER_SLEEVE); }else if(m_shrinksleeve_rbtn->isChecked()){ m_standardpart->setNum(standardPart::SHRINK_SLEEVE); }else if(m_identificationsleeve_rbtn->isChecked()){ m_standardpart->setNum(standardPart::IDENTIFICATION_SLEEVE); }else if(m_conduit_rbtn->isChecked()){ m_standardpart->setNum(standardPart::CONDUIT); }else if(m_wirematerial_rbtn->isChecked()){ m_standardpart->setNum(standardPart::WIRE_MATERIAL); } }
#ifndef PARTNUMBERPAGE_H #define PARTNUMBERPAGE_H #include <QWizardPage> class QLabel; class PartNumberPage : public QWizardPage { Q_OBJECT public: PartNumberPage(QWidget* parent = nullptr); // ~PartNumberPage(){} private: QLabel* m_test; // QWizardPage interface public: int nextId() const override; }; #endif // PARTNUMBERPAGE_H
#include "partnumberpage.h" #include <QLabel> #include <QBoxLayout> #include "shared_defs.h" PartNumberPage::PartNumberPage(QWidget* parent) : QWizardPage( parent ) { setObjectName("partNumberPage"); setTitle(tr("Part number")); setSubTitle(tr("Electrical standard part with the subordinated item.")); QBoxLayout* mainLayout = new QVBoxLayout; mainLayout->addWidget(m_test = new QLabel); } int PartNumberPage::nextId() const { return ALTIDENT_PAGE; }
- Код самого Wizard
#ifndef WIZARDSTANDARDPART_H #define WIZARDSTANDARDPART_H #include <QWizard> #include "intropage.h" #include "partnumberpage.h" #include "shared_defs.h" namespace Ui { class WizardStandardPart; } class WizardStandardPart : public QWizard { Q_OBJECT public: explicit WizardStandardPart(QWidget *parent = nullptr); ~WizardStandardPart(); private: Ui::WizardStandardPart *ui; }; #endif // WIZARDSTANDARDPART_H
#include "wizardstandardpart.h" #include "ui_wizardstandardpart.h" #include "shared_defs.h" WizardStandardPart::WizardStandardPart(QWidget *parent) : QWizard(parent), ui(new Ui::WizardStandardPart) { setWindowTitle(tr("License Wizard")); ui->setupUi(this); setPage(INTRO_PAGE, new IntroPage(this)); setPage(PARTNUMBER_PAGE, new PartNumberPage(this)); setStartId(INTRO_PAGE); } WizardStandardPart::~WizardStandardPart() { delete ui; }
- Как вызываю Wizard (mainwindow.cpp):
... void MainWindow::actionCreateStandardPartObject() { WizardStandardPart *wizardStandardPart = new WizardStandardPart(); qDebug() << wizardStandardPart->page(INTRO_PAGE)->title(); qDebug() << wizardStandardPart->page(PARTNUMBER_PAGE)->title(); wizardStandardPart->exec(); } ...
Вот что выводится при запуске wizard:
Но количество страниц в Wizard точно две, потому что я могу получить их свойсва title.
Всем спасибо за помощь заранее.
Делаю так первый раз, может быть что-то упускаю.
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.Do you like it? Share on social networks!
d
- dsfs
- April 26, 2024, 2:56 p.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:80points,
- Rating points4
d
- dsfs
- April 26, 2024, 2:35 p.m.
C++ - Test 001. The first program and data types
- Result:73points,
- Rating points1
Last comments
Qt Linux - Lesson 001. Autorun Qt application under Linux как сделать автозапуск для флэтпака, который не даёт создавать файлы в ~/.config - вот это вопрос ))
АК
Qt WinAPI - Lesson 007. Working with ICMP Ping in Qt Без строки #include <QRegularExpressionValidator> в заголовочном файле не работает валидатор.
Анатолий КононенкоFeb. 5, 2024, 12:50 p.m.
EVADec. 25, 2023, 9:30 p.m.
Boost - static linking in CMake project under Windows Сделал всё по-как у вас, но выдаёт ошибку [build] LINK : fatal error LNK1104: не удается открыть файл "libboost_locale-vc142-mt-gd-x64-1_74.lib" Хоть убей, не могу понять в чём дел…
Qt/C++ - Lesson 056. Connecting the Boost library in Qt for MinGW and MSVC compilers Для решения твой проблемы добавь в файл .pro строчку "LIBS += -lws2_32" она решит проблему , лично мне помогло.
Now discuss on the forum
DA
Unlock Your Aesthetic Potential: Explore MSC in Facial Aesthetics and Cosmetology in India Embark on a transformative journey with an msc in facial aesthetics and cosmetology in india . Delve into the intricate world of beauty and rejuvenation, guided by expert faculty and …
Dr Gangil AcademicsApril 20, 2024, 5:45 p.m.
Мобильное приложение на C++Qt и бэкенд к нему на Django Rest Framework Евгений, добрый день! Такой вопрос. Верно ли следующее утверждение: Любое Android-приложение, написанное на Java/Kotlin чисто теоретически (пусть и с большими трудностями) можно написать и на C+…
Павел ДорофеевApril 14, 2024, 12:35 p.m.
Вернуть старое поведение QComboBox, не менять индекс при resetModel Добрый день! У нас много проектов в которых используется QComboBox, в версии 5.5.1, когда модель испускает сигнал resetModel, currentIndex не менялся. В версии 5.15 при resetModel происходит try…
Добрый день
А там нет ещё какого-нибудь кода с кнопками. Мне кажется, что там что-то должно быть, чтобы делать кнопку активной.
Но я в упор не вижу у вас подобного кода.
Евгений, добрый день.
Я просмотрел кучу примеров и ничего подобного не нашел.
Кнопки нигде не описываются. Для меня это тоже показалось странным. Я подумал, что это отдается на откуп самому wizard.
Ну вообще у меня есть ещё такая мысль, что необходимо вызывать соответсвующие методы родительского класса страницы