problem bei Compiler

Du bist neu in der Welt von C++? Dann schau hier herein!
Antworten
sewa
Beiträge: 9
Registriert: 18. März 2011 15:38

problem bei Compiler

Beitrag von sewa »

Hallo zusammen,

ich habe ein Beispiel von einem QT-Buch eins zu eins kopiert und beim Komplieren bekomme ich die folgende Fehlermeldung:

main.o: In function `main':
main.cpp:(.text+0x79): undefined reference to `FunctionPlot::FunctionPlot(int, QWidget*, char const*)'
main.cpp:(.text+0xef): undefined reference to `FunctionPlot::setValue(int, valuePair)'
main.cpp:(.text+0x10f): undefined reference to `FunctionPlot::plotIt()'
collect2: ld returned 1 exit status

hier sind Codeabschnitte:

functionplot.h

#ifndef FUNCTIONPLOT_H
#define FUNCTIONPLOT_H
#include <qapplication.h>
#include <qwidget.h>

typedef struct {
double x,y;
} valuePair;
class FunctionPlot: public QWidget{
public:
FunctionPlot(int n, QWidget *p=0, const char *name=0);
~FunctionPlot() {delete [] values;}
void plotIt(void);

functionplot.cpp

#include <qpainter.h>
#include <stdio.h>
#include "functionplot.h"

FunctionPlot::FunctionPlot( int n, QWidget *p, const char *name )
: QWidget( p, name ) {
valueNo = n;
values = new valuePair [n];
for ( int i=0; i<n; i++ )
values.x = values.y = 0.0;
plotViewSet = false;
}
void FunctionPlot::plotIt( void ) {
if ( !plotViewSet ) {

min.cpp:

int main( int argc, char *argv[])
{
QApplication myapp(argc, argv);
const double pi=4*atan(1);
valuePair v;
int i=0, z=0;
double x=0.0;
for(x=-2*pi; x<3*pi;x+=0.01){
z++;
}
FunctionPlot* plotWindow= new FunctionPlot(z);
plotWindow->resize(500,500);
for(v.x=-2*i; v.x<3*pi;v.x+=0.01){
v.y= sin(v.x);
plotWindow->setValue(i, v);
i++;}
plotWindow->plotIt();
//myapp.setMainWidget(plotWindow);
plotWindow->show();

ich bin für jede Hilfe sehr dankbar.

PC:
ich arbeite mt qt4.


[/code]
Christian81
Beiträge: 7319
Registriert: 26. August 2004 14:11
Wohnort: Bremen
Kontaktdaten:

Beitrag von Christian81 »

Ich würde sagen funcplot.cpp wird nicht mit kompiliert... http://doc.trolltech.com/4.7/qmake-vari ... ml#sources
MfG Christian

'Funktioniert nicht' ist keine Fehlerbeschreibung
sewa
Beiträge: 9
Registriert: 18. März 2011 15:38

Error in Construction

Beitrag von sewa »

hallo Christian

Sie haben recht aber der compiler meldet jetzt die folg. Meldung:

functionplot.cpp: In constructor â FunctionPlot::FunctionPlot(int, QWidget*, const char*)â:
functionplot.cpp:7: error: no matching function for call to â QWidget::QWidget(QWidget*&,const char*&) â
/usr/include/qt4/QtGui/qwidget.h:787: note: candidates are: QWidget::QWidget(const QWidget&)
/usr/include/qt4/QtGui/qwidget.h:714: note: QWidget::QWidget(QWidgetPrivate&,QWidget*, Qt::WindowFlags)
/usr/include/qt4/QtGui/qwidget.h:224: note: QWidget::QWidget(QWidget*,Qt::WindowFlags)
make: *** [functionplot.o] Fehler 1

Gruß

Sewa
Christian81
Beiträge: 7319
Registriert: 26. August 2004 14:11
Wohnort: Bremen
Kontaktdaten:

Beitrag von Christian81 »

Der Compiler hat ja auch recht - siehe http://doc.trolltech.com/4.7/qwidget.html#QWidget ...
Das const char * im ctor sieht mir eher wie Qt3 aus ...
MfG Christian

'Funktioniert nicht' ist keine Fehlerbeschreibung
sewa
Beiträge: 9
Registriert: 18. März 2011 15:38

Beitrag von sewa »

danke sehr es hat geklappt.


beste Grüße

Sewa
selim181
Beiträge: 1
Registriert: 9. Juni 2011 15:16
Wohnort: Remscheid

fplot

Beitrag von selim181 »

Hallo Sewa
Ich habe auch das gleiche Quelltext vom "Das Qt Buch" kopiert und habe das
gleiche Problem. Mich würde interessieren welche Änderungen du vorgenommen hast.

Gruß
Antworten