PDA

View Full Version : Q3Canvas on qt4



freegnu
12th June 2006, 14:07
http://doc.trolltech.com/4.0/porting4.html#qcanvas
according the reference
"The canvas module classes have been renamed and moved to the Qt3Support library"
canvas module classes is also support by qt4, but when i build the code , the error says
it cant find Q3Canvas ...


#include <qapplication.h>
#include <q3canvas.h>

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

Q3Canvas canvas( 800, 600 );
canvas.setAdvancePeriod(30);

Q3CavasView m;
m.setCanvas(&canvas);
a.setMainWidget(&m);

Q3CanvasLine* i = new QCanvasLine(&canvas);
i->setPoints( rand()%canvas.width(), rand()%canvas.height(),
rand()%canvas.width(), rand()%canvas.height() );
i->setPen( QPen(QColor(rand()%32*8, rand()%32*8, rand()%32*8), 6) );
i->setZ(rand()%256);
i->show();

m.show();

return a.exec();
}




main.cpp:2:22: q3canvas.h: No such file or directory
main.cpp: In function `int qMain(int, char**)':
main.cpp:8: error: `Q3Canvas' undeclared (first use this function)
main.cpp:8: error: (Each undeclared identifier is reported only once for each function it appears in.)
main.cpp:8: error: expected `;' before "canvas"
main.cpp:9: error: `canvas' undeclared (first use this function)
main.cpp:11: error: `Q3CavasView' undeclared (first use this function)
main.cpp:11: error: expected `;' before "m"
main.cpp:12: error: `m' undeclared (first use this function)
main.cpp:13: error: 'class QApplication' has no member named 'setMainWidget'
main.cpp:15: error: `Q3CanvasLine' undeclared (first use this function)
main.cpp:15: error: `i' undeclared (first use this function)
main.cpp:15: error: `QCanvasLine' has not been declared
main.cpp:18: error: invalid use of undefined type `struct QColor'
C:/Qt/4.1.2/include/QtGui/../../src/gui/kernel/qwindowdefs.h:37: error: forward declaration of `struct QColor'
main.cpp:18: error: invalid use of undefined type `struct QPen'
C:/Qt/4.1.2/include/QtGui/../../src/gui/kernel/qwindowdefs.h:52: error: forward declaration of `struct QPen'
main.cpp:25:2: warning: no newline at end of file
mingw32-make[1]: *** [tmp\obj\debug_shared\main.o] Error 1
mingw32-make[1]: Leaving directory `C:/Qt/4.1.2/test/test'
mingw32-make: *** [debug-all] Error 2

jpn
12th June 2006, 14:15
To link against Qt3Support module, add this line to your qmake .pro file:

QT += qt3support

munna
12th June 2006, 14:15
Why dont you first include the other required header files also and then try ?

I think the other files are

Q3CanvasView
Q3CanvasLine
QColor
QPen

freegnu
13th June 2006, 01:45
Why dont you first include the other required header files also and then try ?

I think the other files are

Q3CanvasView
Q3CanvasLine
QColor
QPen

sorry i have include the file , but it has the same error

munna
13th June 2006, 06:07
As jpn said

add - QT += qt3support in your .pro file and then make.

wysota
13th June 2006, 10:08
Or download the port of QCanvas to Qt4 which is available on Trolltech's ftp site.