Results 1 to 14 of 14

Thread: Strange error while using Q3Canvas

  1. #1
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy Strange error while using Q3Canvas

    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
    Qt Code:
    1. #include "canvassample.h"
    2. #include <QtGui/QPixmap>
    3.  
    4. CanvasSample::CanvasSample(Q3Canvas *canvas) : Q3CanvasView(canvas)
    5. {
    6. canvas = new Q3Canvas(100,100);
    7. canvas->setBackgroundColor( Qt::black );
    8. canvas->setBackgroundPixmap( QPixmap( "stars.png" ) );
    9. }
    10. CanvasSample::~CanvasSample()
    11. {
    12. }
    To copy to clipboard, switch view to plain text mode 

    CanvasSample.h
    Qt Code:
    1. #ifndef CANVASSAMPLE_H
    2. #define CANVASSAMPLE_H
    3.  
    4. #include <qt/q3canvas.h>
    5.  
    6. class CanvasSample : public Q3CanvasView
    7. {
    8. public:
    9. CanvasSample(Q3Canvas *canvas);
    10. ~CanvasSample();
    11. private:
    12. Q3Canvas *canvas;
    13. };
    14.  
    15.  
    16. #endif
    To copy to clipboard, switch view to plain text mode 

    Main.cpp
    Qt Code:
    1. #include <qapplication.h>
    2. #include <canvassample.h>
    3.  
    4. int main(int argc, char ** argv)
    5. {
    6. QApplication app(argc,argv);
    7.  
    8. Q3Canvas *canvas;
    9. CanvasSample *samp = new CanvasSample(canvas);
    10. samp->show();
    11. return app.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Strange error while using Q3Canvas

    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 ?
    a life without programming is like an empty bottle

  3. #3
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Strange error while using Q3Canvas

    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:

    [HTML]
    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:aintEvent(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

    [/HTML]

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Strange error while using Q3Canvas

    Do you have "QT += qt3support" in your .pro-file?

  5. #5
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Strange error while using Q3Canvas

    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

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Strange error while using Q3Canvas

    You pass an uninitialized pointer for the Q3CanvasView() constructor.

    main.cpp
    Qt Code:
    1. #include <QApplication>
    2. #include "canvassample.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. CanvasSample s;
    8. s.show();
    9. a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    canvassample.h
    Qt Code:
    1. #ifndef CANVASSAMPLE_H
    2. #define CANVASSAMPLE_H
    3.  
    4. #include <Q3CanvasView>
    5.  
    6. class CanvasSample : public Q3CanvasView
    7. {
    8. Q_OBJECT
    9.  
    10. public:
    11. CanvasSample();
    12. ~CanvasSample();
    13. };
    14.  
    15. #endif // CANVASSAMPLE_H
    To copy to clipboard, switch view to plain text mode 

    canvassample.cpp
    Qt Code:
    1. #include <QPixmap>
    2. #include <Q3Canvas>
    3. #include "canvassample.h"
    4.  
    5. CanvasSample::CanvasSample() : Q3CanvasView()
    6. {
    7. QPixmap pixmap("stars.png");
    8. setCanvas(new Q3Canvas(pixmap.width(),pixmap.height()));
    9. canvas()->setBackgroundColor(Qt::black);
    10. canvas()->setBackgroundPixmap(pixmap);
    11. }
    12.  
    13. CanvasSample::~CanvasSample()
    14. {
    15. }
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to jpn for this useful post:

    Kapil (22nd March 2006)

  8. #7
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Strange error while using Q3Canvas

    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

  9. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Strange error while using Q3Canvas

    Quote Originally Posted by Kapil
    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
    Quote Originally Posted by Kapil
    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..

  10. #9
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Strange error while using Q3Canvas

    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

  11. #10
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Strange error while using Q3Canvas

    Emm I dont think so ..you must create independent QCanvas widget(parent - your QMainWindow) and put it in your QMainWindow vacant area
    a life without programming is like an empty bottle

  12. #11
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Strange error while using Q3Canvas

    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

  13. #12
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Strange error while using Q3Canvas

    Quote Originally Posted by Kapil
    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.

  14. #13
    Join Date
    Jun 2006
    Posts
    8
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Strange error while using Q3Canvas

    Quote Originally Posted by jpn
    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?

  15. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Strange error while using Q3Canvas

    No. You should place it manually in code:

    Qt Code:
    1. QCanvasView *cv = new QCanvasView(canvas, this);
    2. // depending on the type of "this", you might also need:
    3. layout()->add(cv);
    To copy to clipboard, switch view to plain text mode 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.