QT Designer - using .ui file tutorial bug?
-
section - The Direct Approach
Ui::CalculatorForm ui; // this not works (calculatorform not memember of UI namespace)
ui.setupUi(widget);QWidget *w = new QWidget;
Ui::Form ui; // intelisense give me Form and this works fine
ui.setupUi(w);Some wrong setting in creator settings or obsolete docu?
for Qt newbie (like me ) its little bit frustrating.
thanks for answers -
are you referring to this "example":http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html#the-direct-approach ?
if so, did you add@
#include "ui_calculatorform.h"
@at the top?
even with that though, i was not able to make it work properly.
providing a QWidget only allows a root widget element to be there so that the rest of the widgets can use it as parent and draw themselves.there is no way to provide functionality with user provided slots.
what i did was to have my main.cpp as@
#include <QApplication>
#include "calculatorform.h"int main(int argc, char *argv[])
{
QApplication app(argc, argv);CalculatorForm *widget = new CalculatorForm; widget->show(); return app.exec();
}
@and in calculatorform.cpp
@
#include <QtGui>
#include "calculatorform.h"
#include "ui_calculatorform.h"CalculatorForm::CalculatorForm(QWidget *parent)
: QWidget(parent),
ui(new Ui::CalculatorForm)
{
ui->setupUi(this);
}CalculatorForm::~CalculatorForm(void) {
delete ui;
}...
@ -
thanks for answer.
yes i refered that example.i found what was wrong. In Qt Designer the widgets property objectName has default value "Form". After change to "CalculatorForm" is all ok.
exactly like in the example.regards