Seite 1 von 1

problem bei Compiler

Verfasst: 18. März 2011 17:51
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]

Verfasst: 18. März 2011 18:11
von Christian81
Ich würde sagen funcplot.cpp wird nicht mit kompiliert... http://doc.trolltech.com/4.7/qmake-vari ... ml#sources

Error in Construction

Verfasst: 18. März 2011 18:33
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

Verfasst: 18. März 2011 18:37
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 ...

Verfasst: 18. März 2011 19:33
von sewa
danke sehr es hat geklappt.


beste Grüße

Sewa

fplot

Verfasst: 9. Juni 2011 16:25
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ß