Syntax Fehler
Verfasst: 8. Oktober 2008 09:18
Fehlermeldung: In file included from src/mainwindowimpl.cpp:1:
src/mainwindowimpl.h:21: Fehler: mehrere Typen in einer Deklaration
make: *** [build/mainwindowimpl.o] Fehler 1
Wenn ich MyStandardItemModel.h nicht inkludiere dann gibt es keine Fehlermeldung.
Wenn ich MyStandardItemModel.h vor #include <QMainWindow> und "ui_mainwindow.h" inkludiere gibt es die Fehlermeldung:In file included from /usr/include/qt4/QtGui/qwidget.h:44,
from /usr/include/qt4/QtGui/qmainwindow.h:41,
from /usr/include/qt4/QtGui/QMainWindow:1,
from src/mainwindowimpl.h:5,
from src/mainwindowimpl.cpp:1:
/usr/include/qt4/QtGui/qpalette.h:49: Fehler: expected initializer before »QtGuiModule«
make: *** [build/mainwindowimpl.o] Fehler 1
Könnte mir da bitte wer helfen, wird eher ein Fehler für erfahrene C++ Programmierer sein der ich nicht bin. Danke schon im Voraus
mainwindowimpl.h
mainwindowimpl.cpp
MyStandardItemModel.h
MyStandardItemModel.cpp
src/mainwindowimpl.h:21: Fehler: mehrere Typen in einer Deklaration
make: *** [build/mainwindowimpl.o] Fehler 1
Wenn ich MyStandardItemModel.h nicht inkludiere dann gibt es keine Fehlermeldung.
Wenn ich MyStandardItemModel.h vor #include <QMainWindow> und "ui_mainwindow.h" inkludiere gibt es die Fehlermeldung:In file included from /usr/include/qt4/QtGui/qwidget.h:44,
from /usr/include/qt4/QtGui/qmainwindow.h:41,
from /usr/include/qt4/QtGui/QMainWindow:1,
from src/mainwindowimpl.h:5,
from src/mainwindowimpl.cpp:1:
/usr/include/qt4/QtGui/qpalette.h:49: Fehler: expected initializer before »QtGuiModule«
make: *** [build/mainwindowimpl.o] Fehler 1
Könnte mir da bitte wer helfen, wird eher ein Fehler für erfahrene C++ Programmierer sein der ich nicht bin. Danke schon im Voraus
mainwindowimpl.h
Code: Alles auswählen
#ifndef MAINWINDOWIMPL_H
#define MAINWINDOWIMPL_H
#include <QMainWindow>
#include "ui_mainwindow.h"
#include "MyStandardItemModel.h" //FEHLERQUELLE
class MainWindowImpl : public QMainWindow, public Ui::MainWindow
{
Q_OBJECT
public:
MainWindowImpl( QWidget * parent = 0, Qt::WFlags f = 0 );
~MainWindowImpl();
private slots:
void newPruefung();
void showPruefungen();
};
#endif
mainwindowimpl.cpp
Code: Alles auswählen
#include "mainwindowimpl.h"
MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f) : QMainWindow(parent, f)
{
setupUi(this);
}
void MainWindowImpl::showPruefungen()
{
tv_Pruefungen->setModel(new MyStandartItemModel());
}
void MainWindowImpl::newPruefung()
{
}
MainWindowImpl::~MainWindowImpl()
{
}
MyStandardItemModel.h
Code: Alles auswählen
#ifndef __MYSTANDARDITEMMODEL_H__
#define __MYSTANDARDITEMMODEL_H__
#include <qstandarditemmodel.h>
#include "qsqldatabase.h"
#include "myDatabase.h"
class MyStandartItemModel : public QStandardItemModel
{
private:
MyDatabase *myDb;
public:
MyStandartItemModel();
~MyStandartItemModel();
void setItems(QString auswahlKriterium);
}
#endif // __MYSTANDARDITEMMODEL_H__
Code: Alles auswählen
#include "MyStandardItemModel.h"
#include "qsqlquery.h"
MyStandartItemModel::MyStandartItemModel() : QStandardItemModel()
{
myDb = new MyDatabase("verwaltung");
}
void MyStandartItemModel::setItems(QString auswahlKriterium)
{
QSqlQuery myQuery(myDb->myDbQuery("Select * from ..."));
int i=0;
while(myQuery.next())
{
setItem(i,0, new QStandardItem(myQuery.value(0).toString()));
setItem(i,1, new QStandardItem(myQuery.value(1).toString()));
setItem(i,2, new QStandardItem(myQuery.value(2).toString()));
setItem(i,3, new QStandardItem(myQuery.value(3).toString()));
setItem(i,4, new QStandardItem(myQuery.value(4).toString()));
setItem(i,5, new QStandardItem(myQuery.value(5).toString()));
setItem(i,6, new QStandardItem(myQuery.value(6).toString()));
i++;
}
}
MyStandartItemModel::~MyStandartItemModel()
{
}