PDA

View Full Version : Strange error while using Q3Canvas



Kapil
22nd March 2006, 05:42
Hi...

I have written a small application using Q3Canvas... i have got a Big List of errors.. i culdnt understand why it was as i have all the header files included and present.
i am pasting the code of the three files... i culdnt understand the error....

CanvasView.cpp


#include "canvassample.h"
#include <QtGui/QPixmap>

CanvasSample::CanvasSample(Q3Canvas *canvas) : Q3CanvasView(canvas)
{
canvas = new Q3Canvas(100,100);
canvas->setBackgroundColor( Qt::black );
canvas->setBackgroundPixmap( QPixmap( "stars.png" ) );
}
CanvasSample::~CanvasSample()
{
}


CanvasSample.h


#ifndef CANVASSAMPLE_H
#define CANVASSAMPLE_H

#include <qt/q3canvas.h>

class CanvasSample : public Q3CanvasView
{
public:
CanvasSample(Q3Canvas *canvas);
~CanvasSample();
private:
Q3Canvas *canvas;
};


#endif



Main.cpp


#include <qapplication.h>
#include <canvassample.h>

int main(int argc, char ** argv)
{
QApplication app(argc,argv);

Q3Canvas *canvas;
CanvasSample *samp = new CanvasSample(canvas);
samp->show();
return app.exec();
}

zlatko
22nd March 2006, 06:18
Fist off all show us your strange errors :)
Second just remark : why are you decalre Q3Canvas pointer in main and then put it in your class if you doesnt use it in main later ?

Kapil
22nd March 2006, 06:42
Hi,

i created the Q3Canvas in the main to intiate the canvas. I passed the same to the CanvasSample.cpp... Ya it can be said that the canvas variable that i have created in the CanvasSample.h is of no use. That i can remove....

The canvas object which i have created in main, is sent to the CanvasSample.cpp and using that object the Canvas is created..

The errors are:



release\canvassample.o(.text+0x8e):canvassample.cp p: undefined reference to `_im
p___ZN12Q3CanvasViewC2EP8Q3CanvasP7QWidgetPKc6QFla gsIN2Qt10WindowTypeEE'
release\canvassample.o(.text+0xd2):canvassample.cp p: undefined reference to `_im
p___ZN8Q3CanvasC1Eii'
release\canvassample.o(.text+0x293):canvassample.c pp: undefined reference to `_i
mp___ZN12Q3CanvasViewD2Ev'
release\canvassample.o(.text+0x3be):canvassample.c pp: undefined reference to `_i
mp___ZN12Q3CanvasViewC2EP8Q3CanvasP7QWidgetPKc6QFl agsIN2Qt10WindowTypeEE'
release\canvassample.o(.text+0x402):canvassample.c pp: undefined reference to `_i
mp___ZN8Q3CanvasC1Eii'
release\canvassample.o(.text+0x5c3):canvassample.c pp: undefined reference to `_i
mp___ZN12Q3CanvasViewD2Ev'
release\canvassample.o(.text+0x67b):canvassample.c pp: undefined reference to `_i
mp___ZN12Q3CanvasViewD2Ev'
release\canvassample.o(.text+0x6ab):canvassample.c pp: undefined reference to `_i
mp___ZN12Q3CanvasViewD2Ev'
release\canvassample.o(.text+0x6dc):canvassample.c pp: undefined reference to `_i
mp___ZN12Q3CanvasViewD2Ev'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x8):c
anvassample.cpp: undefined reference to `Q3CanvasView::metaObject() const'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0xc):c
anvassample.cpp: undefined reference to `Q3CanvasView::qt_metacast(char const*)'

release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x10):
canvassample.cpp: undefined reference to `Q3CanvasView::qt_metacall(QMetaObject:
:Call, int, void**)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x20):
canvassample.cpp: undefined reference to `Q3ScrollView::eventFilter(QObject*, QE
vent*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x3c):
canvassample.cpp: undefined reference to `Q3ScrollView::setVisible(bool)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x40):
canvassample.cpp: undefined reference to `Q3CanvasView::sizeHint() const'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x44):
canvassample.cpp: undefined reference to `Q3ScrollView::minimumSizeHint() const'

release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x58):
canvassample.cpp: undefined reference to `Q3ScrollView::mousePressEvent(QMouseEv
ent*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x5c):
canvassample.cpp: undefined reference to `Q3ScrollView::mouseReleaseEvent(QMouse
Event*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x60):
canvassample.cpp: undefined reference to `Q3ScrollView::mouseDoubleClickEvent(QM
ouseEvent*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x64):
canvassample.cpp: undefined reference to `Q3ScrollView::mouseMoveEvent(QMouseEve
nt*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x68):
canvassample.cpp: undefined reference to `Q3ScrollView::wheelEvent(QWheelEvent*)
'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x84):
canvassample.cpp: undefined reference to `Q3Frame::paintEvent(QPaintEvent*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x8c):
canvassample.cpp: undefined reference to `Q3ScrollView::resizeEvent(QResizeEvent
*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x94):
canvassample.cpp: undefined reference to `Q3ScrollView::contextMenuEvent(QContex
tMenuEvent*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0xcc):
canvassample.cpp: undefined reference to `Q3ScrollView::focusNextPrevChild(bool)
'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0xd0):
canvassample.cpp: undefined reference to `Q3ScrollView::styleChange(QStyle&)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0xdc):
canvassample.cpp: undefined reference to `Q3ScrollView::fontChange(QFont const&)
'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x124)
:canvassample.cpp: undefined reference to `Q3ScrollView::contentsMouseReleaseEve
nt(QMouseEvent*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x128)
:canvassample.cpp: undefined reference to `Q3ScrollView::contentsMouseDoubleClic
kEvent(QMouseEvent*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x12c)
:canvassample.cpp: undefined reference to `Q3ScrollView::contentsMouseMoveEvent(
QMouseEvent*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x130)
:canvassample.cpp: undefined reference to `Q3ScrollView::contentsDragEnterEvent(
QDragEnterEvent*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x134)
:canvassample.cpp: undefined reference to `Q3ScrollView::contentsDragMoveEvent(Q
DragMoveEvent*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x138)
:canvassample.cpp: undefined reference to `Q3ScrollView::contentsDragLeaveEvent(
QDragLeaveEvent*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x13c)
:canvassample.cpp: undefined reference to `Q3ScrollView::contentsDropEvent(QDrop
Event*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x140)
:canvassample.cpp: undefined reference to `Q3ScrollView::contentsWheelEvent(QWhe
elEvent*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x168)
:canvassample.cpp: undefined reference to `Q3ScrollView::viewportDragLeaveEvent(
QDragLeaveEvent*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x16c)
:canvassample.cpp: undefined reference to `Q3ScrollView::viewportDropEvent(QDrop
Event*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x170)
:canvassample.cpp: undefined reference to `Q3ScrollView::viewportWheelEvent(QWhe
elEvent*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x174)
:canvassample.cpp: undefined reference to `Q3ScrollView::viewportContextMenuEven
t(QContextMenuEvent*)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x178)
:canvassample.cpp: undefined reference to `Q3ScrollView::setMargins(int, int, in
t, int)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x17c)
:canvassample.cpp: undefined reference to `Q3ScrollView::setHBarGeometry(QScroll
Bar&, int, int, int, int)'
release\canvassample.o(.rdata$_ZTV12CanvasSample[vtable for CanvasSample]+0x180)
:canvassample.cpp: undefined reference to `Q3ScrollView::setVBarGeometry(QScroll
Bar&, int, int, int, int)'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [release\qtcanvas.exe] Error 1
mingw32-make[1]: Leaving directory `D:/Kapil_Folder/qtcanvas'
mingw32-make: *** [release] Error 2

jpn
22nd March 2006, 06:45
Do you have "QT += qt3support" in your .pro-file?

Kapil
22nd March 2006, 06:53
Hi,

Thanks.. yaa after including it, the errors got removed but then there is i suppose a runtime memory error in the code.. 'coz the .exe created is not running and is giving the reference error...

what error can be there in the code posted above????

Kapil

jpn
22nd March 2006, 06:58
You pass an uninitialized pointer for the Q3CanvasView() constructor.

main.cpp


#include <QApplication>
#include "canvassample.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
CanvasSample s;
s.show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}


canvassample.h


#ifndef CANVASSAMPLE_H
#define CANVASSAMPLE_H

#include <Q3CanvasView>

class CanvasSample : public Q3CanvasView
{
Q_OBJECT

public:
CanvasSample();
~CanvasSample();
};

#endif // CANVASSAMPLE_H


canvassample.cpp


#include <QPixmap>
#include <Q3Canvas>
#include "canvassample.h"

CanvasSample::CanvasSample() : Q3CanvasView()
{
QPixmap pixmap("stars.png");
setCanvas(new Q3Canvas(pixmap.width(),pixmap.height()));
canvas()->setBackgroundColor(Qt::black);
canvas()->setBackgroundPixmap(pixmap);
}

CanvasSample::~CanvasSample()
{
}

Kapil
22nd March 2006, 07:12
Hi,

Thanks,
That worked but its unable to show the pixmap....

also i wanted to know that as the canvas does not have the Toolbar and MenuBar options like MainWindow or a Wdiget, so can i have a canvas over a MainWindow or a Widget..

Kapil

jpn
22nd March 2006, 07:21
That worked but its unable to show the pixmap....
Do you have the png file in the running directory?
Note that the running directory is not necessarily always the same than where the .exe is located. If you launch the .exe from command line, then the running directory is the same than where the exe is located.
A reliable solution is to compile your pixmap into resources ;)


also i wanted to know that as the canvas does not have the Toolbar and MenuBar options like MainWindow or a Wdiget, so can i have a canvas over a MainWindow or a Widget..

Yes, Q3CanvasView inherits QWidget so it can be set as a central widget into a QMainWindow. If that's what you were asking.. :)

Kapil
22nd March 2006, 07:41
Hi,

I have made a QMainWindow Form... Now it has few panels and Tollbar+MenuBar options declared on it.. There is a central vacant area where the QCanvas has to display the results. So can QCanvas be called on that central region of the QMainWindow form and not as an independent window..

Kapil

zlatko
22nd March 2006, 07:45
Emm I dont think so ..you must create independent QCanvas widget(parent - your QMainWindow) and put it in your QMainWindow vacant area

Kapil
22nd March 2006, 07:48
Hi,

This means that i will have to redirect the output to a canvas window and then display the result. Is it so?

Then how do i place that QCanvas window on my QMainWindow at the exact location?

Kapil

jpn
22nd March 2006, 08:03
how do i place that QCanvas window on my QMainWindow at the exact location?
Q3CanvasView is inherited from QWidget, so you can put it in layouts and so on, like any other type of widgets.

jimadamthwaite
15th June 2006, 18:52
Q3CanvasView is inherited from QWidget, so you can put it in layouts and so on, like any other type of widgets.

Could you please point to an example of this? I have exactly the same problem - that of placing a canvas view in a controlled position on MY window, rather than in a second unplanned window. I do not seem to have a Q3CanvasView available in the widget box. Should it be?

wysota
15th June 2006, 19:36
No. You should place it manually in code:


QCanvasView *cv = new QCanvasView(canvas, this);
// depending on the type of "this", you might also need:
layout()->add(cv);