implementing a dynamic display
-
I've tried to implement a new class (patterned after my main form)...obviously I don't understand something.
Here's the header:
#ifndef CREDENTIALS_H #define CREDENTIALS_H #include <QWidget> namespace Ui { class Credentials; } class Credentials : public QWidget { Q_OBJECT public: explicit Credentials(QWidget *parent = nullptr); private: Ui::Credentials *uiCredentials; }; #endif // CREDENTIALS_H
and here's the source:
#include "credentials.h" #include "ui_credentials.h" Credentials::Credentials(QWidget *parent) : QWidget(parent), uiCredentials(new Ui::Credentials) { uiCredentials->setupUi(this); }
I'm getting an error "invalid use of incomplete type 'class Ui::Credentials'. Why is it incomplete?
-
I've tried to implement a new class (patterned after my main form)...obviously I don't understand something.
Here's the header:
#ifndef CREDENTIALS_H #define CREDENTIALS_H #include <QWidget> namespace Ui { class Credentials; } class Credentials : public QWidget { Q_OBJECT public: explicit Credentials(QWidget *parent = nullptr); private: Ui::Credentials *uiCredentials; }; #endif // CREDENTIALS_H
and here's the source:
#include "credentials.h" #include "ui_credentials.h" Credentials::Credentials(QWidget *parent) : QWidget(parent), uiCredentials(new Ui::Credentials) { uiCredentials->setupUi(this); }
I'm getting an error "invalid use of incomplete type 'class Ui::Credentials'. Why is it incomplete?
#include "ui_credentials_form_file_name.h"
-
Did you re-run qmake after adding your new form ?
-
@SGaist Yes. (I just tried it again to be sure.) I even did a clean/qmake/build...same results.
And is the root object of your form called "Credentials" (look for it when you open the form in the designer - in the right, in the object tree the first object's name)?
-
Aha! That did the trick. Thanks, kshegunov. It was simply called "Dialog."
So, the step I missed was matching the name of the top-level object created in Designer with the new class I created manually to support it. I looked past this because the first form (and its supporting class) was created automatically when I started the project.
Thanks again.
-
Aha! That did the trick. Thanks, kshegunov. It was simply called "Dialog."
So, the step I missed was matching the name of the top-level object created in Designer with the new class I created manually to support it. I looked past this because the first form (and its supporting class) was created automatically when I started the project.
Thanks again.
@mzimmers
Hi
Just as a note. you can add as many forms as you like and
have them auto created like mainwindow is.It sounds you manually created Credentials ?
To get a new form, simply right click top of project, select "Add new" and then
In next window, you can choose if it should be MainWindow, Dialog or Widget.This way you get .ui, cpp and h all ready to go.
maybe i misunderstood but just in case :)
-
@mzimmers
Hi
Just as a note. you can add as many forms as you like and
have them auto created like mainwindow is.It sounds you manually created Credentials ?
To get a new form, simply right click top of project, select "Add new" and then
In next window, you can choose if it should be MainWindow, Dialog or Widget.This way you get .ui, cpp and h all ready to go.
maybe i misunderstood but just in case :)
-
@mrjj oh, that's good to know about. I looked right past that and just created the form from the line below. Thanks, mrjj...I'll remember that for the (not so distant) future.