Ich verzweifel grad daran, ganz einfach eingene Variablen in einer Klasse zu benutzen.
Ich habe die Dateien mainwindow.h mainwindow.cpp und mainwindow.ui.h, die zu einem mit dem Designer erstellten Dialog gehören:
mainwindow.h
Code: Alles auswählen
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qvariant.h>
#include <qdialog.h>
#include <qhttp.h>
class QVBoxLayout;
class QHBoxLayout;
// (...)
class MainWindow : public QDialog
{
Q_OBJECT
public:
MainWindow( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~MainWindow();
QLabel* textLabel1;
QLineEdit* line_server;
// (...)
public slots:
virtual void startButtonClicked();
virtual void httpRequestFinished( int requestId, bool error );
protected:
QVBoxLayout* layout12;
// (...)
protected slots:
virtual void languageChange();
// ---> Meine Variablen: <---
private:
QHttp http;
int httpGetId;
};
#endif // MAINWINDOW_HCode: Alles auswählen
#include "mainwindow.h"
#include <qvariant.h>
// (...)
#include "mainwindow.ui.h"
/*
* Constructs a MainWindow as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
MainWindow::MainWindow( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
// (...)
}
/*
* Destroys the object and frees any allocated resources
*/
MainWindow::~MainWindow()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void MainWindow::languageChange()
{
// (...)
}Code: Alles auswählen
void MainWindow::startButtonClicked()
{
// Problemstelle --->
http.setHost( line_server->text() );
httpGetId = http->get( line_file->text() );
}
void MainWindow::httpRequestFinished( int requestId, bool error )
{
}
Warum? Der müsste die doch kennen.qmake -o Makefile qtonlineviewer.pro
g++ -c -pipe -Wall -W -march=k8 -O2 -pipe -DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT -DQT_THREAD_SUPPORT -I/usr/qt/3/mkspecs/linux-g++ -I. -I/usr/qt/3/include -I.ui/ -I. -I.moc/ -o .obj/mainwindow.o .ui/mainwindow.cpp
In file included from .ui/mainwindow.cpp:23:
.ui/../mainwindow.ui.h: In member function `virtual void MainWindow::startButtonClicked()':
.ui/../mainwindow.ui.h:16: Fehler: »http« nicht deklariert (erste Verwendung dieser Funktion)
.ui/../mainwindow.ui.h:16: Fehler: (Jeder nicht deklarierte Bezeichner wird nur einmal für jede Funktion, in der er vorkommt, gemeldet.)
.ui/../mainwindow.ui.h:17: Fehler: »httpGetId« nicht deklariert (erste Verwendung dieser Funktion)
.ui/../mainwindow.ui.h: At global scope:
.ui/../mainwindow.ui.h:22: Warnung: nicht benutzter Parameter »requestId«
.ui/../mainwindow.ui.h:22: Warnung: nicht benutzter Parameter »error«
make: *** [.obj/mainwindow.o] Fehler 1
Wenn ich die kritischen Zeilen
Code: Alles auswählen
http.setHost( line_server->text() );
httpGetId = http->get( line_file->text() );Wo liegt denn da der Fehler?