QDialog compilation error
Hi. I'm sure this is a really simple question.
I've created a Qt Widget Application.
I then created a QDialog which is to be an About dialog. I used the Qt Designer Form Class and went with a Dialog with Buttons. I only wanted the OK button, and couldn't work out how to remove the Cancel button, so I deleted the buttons and added an OK button.
So far so good.
I then made the following changes to my QMainWindow header file:
Forward declared my Ui::About class.
Added a Ui::About member variable.
I then made the following changes to my QMainWindow CPP file:
Added to the constructor body:
about = new Ui::About(this);
When I compile I get the error:
'Ui::About' : class has no constructors
It's as if I'm using the wrong #include in the QMainWindow CPP file.
If I also add #include "ui_about.h" I get a different error:
'Ui::About::About(const Ui::About &)' : cannot convert argument 1 from 'TargetController *const ' to 'const Ui::About &'
Reason: cannot convert from 'TargetController *const ' to 'const Ui::About'
No constructor could take the source type, or constructor overload resolution was ambiguous
I think I'm misunderstanding the something simple.
Normally you would just include the AboutDialog.h
to show it.
The Ui::About is used internally in the Dialog in the constructor.
So you just construct an instance of your dialog class and it should just work.
ui = new Ui::Notepad; ui->setupUi(this);
Here there's a full example: http://doc.qt.io/qt-5/gettingstartedqt.html