PDA

View Full Version : no appropriate default constructor available



yazan
19th June 2011, 13:56
hi all,
i'm trying to compile my project, that i have made under linux, in windows
graphForm::graphForm(QWidget *parent) :
QMdiSubWindow(parent),
ui(new Ui::graphForm)
in the code with red color i get the following error, although i have no problems in liunx

Fehler:C2512: 'Ui::graphForm' : no appropriate default constructor available
does onybody know what could that be

any help will be apreciated

wysota
19th June 2011, 16:03
Did uic create the Ui::graphForm class for you?

yazan
19th June 2011, 16:45
yes it is created with qt creator

stampede
19th June 2011, 17:24
I think wysota meant the automatically generated class code, created by uic from the form .ui file ( form.ui should give you ui_form.h ).

yazan
19th June 2011, 17:57
yes it does.
i have forgetten to say that i'm trying to compile a project under windows, witch was developed under linux, under linux there is no problems.

stampede
19th June 2011, 18:04
Can you post the content of this header ?

yazan
19th June 2011, 18:18
#include "graphform.h"
#include "ui_graphform.h"
#include "messwertemodel.h"
#include <qwt_plot_curve.h>
#include <qwt_symbol.h>
#include <QDebug>
#include <qwt_plot_grid.h>
#include <QStyledItemDelegate>


graphForm::graphForm(QWidget *parent) :
QMdiSubWindow(parent), ui(new Ui::graphForm)
{
ui->setupUi(this);
this->model=new messwerteModel();
this->ui->messwerteTableView->setModel(this->model);
this->ui->messwertQwtPlot->axisAutoScale(false);
}

stampede
19th June 2011, 19:05
I've meant the automatically generated header: "ui_graphform.h"

yazan
19th June 2011, 19:49
hear it is

/************************************************** ******************************
** Form generated from reading UI file 'graphform.ui'
**
** Created:
** by: Qt User Interface Compiler version 4.7.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
************************************************** ******************************/

#ifndef UI_GRAPHFORM_H
#define UI_GRAPHFORM_H

#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QFrame>
#include <QtGui/QGridLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QRadioButton>
#include <QtGui/QScrollArea>
#include <QtGui/QTabWidget>
#include <QtGui/QTableView>
#include <QtGui/QWidget>
#include "qwt_plot.h"
#include "qwt_text_label.h"

QT_BEGIN_NAMESPACE

class Ui_graphForm
{
public:




QwtPlot *messwertQwtPlot;

void setupUi(QWidget *graphForm)
{
if (graphForm->objectName().isEmpty())
graphForm->setObjectName(QString::fromUtf8("graphForm"));
graphForm->resize(842, 602);
QIcon icon;
icon.addFile(QString::fromUtf8("icons/newGraph.png"), QSize(), QIcon::Normal, QIcon::Off);
graphForm->setWindowIcon(icon);
horizontalLayoutWidget = new QWidget(graphForm);
horizontalLayoutWidget->setObjectName(QString::fromUtf8("horizontalLayoutWidget"));
horizontalLayoutWidget->setGeometry(QRect(10, 30, 831, 321));
horizontalLayout = new QHBoxLayout(horizontalLayoutWidget);
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
horizontalLayout->setContentsMargins(0, 0, 0, 0);
tabWidget_2 = new QTabWidget(graphForm);
tabWidget_2->setObjectName(QString::fromUtf8("tabWidget_2"));
tabWidget_2->setGeometry(QRect(4, 350, 791, 251));
tab_3 = new QWidget();
tab_3->setObjectName(QString::fromUtf8("tab_3"));
scrollArea = new QScrollArea(tab_3);
scrollArea->setObjectName(QString::fromUtf8("scrollArea"));
scrollArea->setGeometry(QRect(0, 10, 631, 214));
scrollArea->setWidgetResizable(true);
scrollAreaWidgetContents = new QWidget();
scrollAreaWidgetContents->setObjectName(QString::fromUtf8("scrollAreaWidgetContents"));
scrollAreaWidgetContents->setGeometry(QRect(0, 0, 627, 210));
gridLayout = new QGridLayout(scrollAreaWidgetContents);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
messwerteTableView = new QTableView(scrollAreaWidgetContents);
messwerteTableView->setObjectName(QString::fromUtf8("messwerteTableView"));
messwerteTableView->setMouseTracking(true);

gridLayout->addWidget(messwerteTableView, 0, 1, 1, 1);

scrollArea->setWidget(scrollAreaWidgetContents);
addMesswertButton = new QPushButton(tab_3);
addMesswertButton->setObjectName(QString::fromUtf8("addMesswertButton"));
addMesswertButton->setGeometry(QRect(680, 10, 41, 27));
QIcon icon1;
icon1.addFile(QString::fromUtf8("icons/plus.png"), QSize(), QIcon::Normal, QIcon::Off);
addMesswertButton->setIcon(icon1);
deleteMesswertButton = new QPushButton(tab_3);
deleteMesswertButton->setObjectName(QString::fromUtf8("deleteMesswertButton"));
deleteMesswertButton->setGeometry(QRect(680, 46, 41, 27));
QIcon icon2;
icon2.addFile(QString::fromUtf8("icons/minus.png"), QSize(), QIcon::Normal, QIcon::Off);
deleteMesswertButton->setIcon(icon2);
linearFrame->setFrameShadow(QFrame::Raised);

aValEdit->setObjectName(QString::fromUtf8("aValEdit"));
aValEdit->setGeometry(QRect(24, 3, 41, 25));
bVarLbl = new QLabel(linearFrame);
bVarLbl->setObjectName(QString::fromUtf8("bVarLbl"));
bVarLbl->setGeometry(QRect(78, 3, 16, 17));


line->setAutoFillBackground(false);
line->setFrameShadow(QFrame::Raised);
line->setLineWidth(8);
pbtnPrint->setIcon(icon3);
pbtnPrint->setIconSize(QSize(32, 32));
pbtnExport = new QPushButton(graphForm);
pbtnExport->setObjectName(QString::fromUtf8("pbtnExport"));
pbtnExport->setGeometry(QRect(806, 500, 30, 31));
QIcon icon4;
icon4.addFile(QString::fromUtf8("icons/pdf.png"), QSize(), QIcon::Normal, QIcon::Off);
pbtnExport->setIcon(icon4);
pbtnExport->setIconSize(QSize(24, 24));
messwertQwtPlot = new QwtPlot(graphForm);
messwertQwtPlot->setObjectName(QString::fromUtf8("messwertQwtPlot"));
messwertQwtPlot->setGeometry(QRect(8, 30, 821, 319));
QWidget::setTabOrder(lineareFunkRadio, aValEdit);
QWidget::setTabOrder(aValEdit, bValEdit);
QWidget::setTabOrder(bValEdit, logFunkRadio);
QWidget::setTabOrder(logFunkRadio, logVarEdit);
QWidget::setTabOrder(logVarEdit, exponentialFunkRadio);
QWidget::setTabOrder(exponentialFunkRadio, exponentialVarEdit);
QWidget::setTabOrder(exponentialVarEdit, sinusFunkRadio);
QWidget::setTabOrder(sinusFunkRadio, sinusAVarEdit);
QWidget::setTabOrder(sinusAVarEdit, quadratischFunkRadio);
QWidget::setTabOrder(quadratischFunkRadio, quadratischVarEdit);
QWidget::setTabOrder(quadratischVarEdit, clearAllButton);
QWidget::setTabOrder(clearAllButton, scrollArea);
QWidget::setTabOrder(scrollArea, drowTXButton);
QWidget::setTabOrder(drowTXButton, drowTYButton);
QWidget::setTabOrder(drowTYButton, drowTYXButton);
QWidget::setTabOrder(drowTYXButton, drowTXYButton);
QWidget::setTabOrder(drowTXYButton, addMesswertButton);
QWidget::setTabOrder(addMesswertButton, deleteMesswertButton);
QWidget::setTabOrder(deleteMesswertButton, messwerteTableView);
QWidget::setTabOrder(messwerteTableView, konstanteFunButton);
QWidget::setTabOrder(konstanteFunButton, ausgleichFunButton);
QWidget::setTabOrder(ausgleichFunButton, tabWidget_2);

retranslateUi(graphForm);
QObject::connect(ausgleichFunButton, SIGNAL(clicked()), graphForm, SLOT(ausgleischFun()));
QObject::connect(exponentialVarEdit, SIGNAL(editingFinished()), graphForm, SLOT(exponentialeFun()));
QObject::connect(konstanteFunButton, SIGNAL(clicked()), graphForm, SLOT(konstanteFun()));
QObject::connect(bValEdit, SIGNAL(editingFinished()), graphForm, SLOT(lineareFun()));
QObject::connect(logVarEdit, SIGNAL(editingFinished()), graphForm, SLOT(logFun()));
QObject::connect(sinusAVarEdit, SIGNAL(editingFinished()), graphForm, SLOT(sinusFun()));
QObject::connect(clearAllButton, SIGNAL(clicked()), graphForm, SLOT(clearAll()));
QObject::connect(graphForm, SIGNAL(destroyed()), graphForm, SLOT(formDestroyed()));
QObject::connect(addMesswertButton, SIGNAL(clicked()), graphForm, SLOT(addMesswert()));
QObject::connect(deleteMesswertButton, SIGNAL(clicked()), graphForm, SLOT(deleteMesswert()));
QObject::connect(drowTXButton, SIGNAL(clicked()), graphForm, SLOT(drowTX()));
QObject::connect(drowTYXButton, SIGNAL(clicked()), graphForm, SLOT(drowTYX()));
QObject::connect(drowTYButton, SIGNAL(clicked()), graphForm, SLOT(drowTY()));
QObject::connect(lineareFunkRadio, SIGNAL(clicked()), graphForm, SLOT(linearVarvisible()));
QObject::connect(logFunkRadio, SIGNAL(clicked()), graphForm, SLOT(logVarVisible()));
QObject::connect(exponentialFunkRadio, SIGNAL(clicked()), graphForm, SLOT(exponetialVarVisible()));
QObject::connect(sinusFunkRadio, SIGNAL(clicked()), graphForm, SLOT(sinusVarVisible()));
QObject::connect(quadratischFunkRadio, SIGNAL(clicked()), graphForm, SLOT(quadratischeVarvisible()));
QObject::connect(pbtnPrint, SIGNAL(clicked()), graphForm, SLOT(print()));
QObject::connect(pbtnExport, SIGNAL(clicked()), graphForm, SLOT(exportInPdf()));

tabWidget_2->setCurrentIndex(1);


QMetaObject::connectSlotsByName(graphForm);
} // setupUi


};

namespace Ui {
class graphForm: public Ui_graphForm {};
} // namespace Ui

QT_END_NAMESPACE

#endif // UI_GRAPHFORM_H


i have shortened the code

wysota
19th June 2011, 20:01
What about the part you cut out? Is there a constructor for the class?

yazan
19th June 2011, 20:22
no there is no constructor.
should not qt be portable. as i have seen one must change his code to get it compiled in win (in my case). i have solved another problem, witch i didn't have in linux.

stampede
19th June 2011, 20:34
How is the member variable ui declared ? You have some kind of forward declaration? Can you post the content of graphform.h ?

SixDegrees
19th June 2011, 20:42
Are you using the same version of Qt/Creator on both systems?

Are you attempting to use automatically generated files created on Linux under Windows?

Have you done a complete 'make clean' of your project and regenerated everything from scratch?

Are you sure this code compiled under Linux? 'cause it doesn't look like it should; there's no constructor corresponding to the object you're trying to construct in the initialization routine.

To answer the question you've repeated several times now: yes, Qt code is, for the most part, portable without change between Linux and Windows. The only exceptions are sections of code that are clearly platform-dependent such as calls to Windows or Linux OS routines or similar resources. I've ported several large programs between the two systems and have never once had to rewrite code.

stampede
19th June 2011, 21:04
But I think there is a default, auto-generated no-argument constructor like for any other C++ class without other constructors, so new Ui::graphForm should be ok.
I agree with SixDegrees, you should rebuild everything from scratch.