Results 1 to 5 of 5

Thread: animting images

  1. #1
    Join Date
    Nov 2007
    Posts
    42
    Thanks
    11
    Qt products
    Qt4
    Platforms
    Unix/X11

    Post animting images

    hello all, i have some flip images of donald duck, so i wanted to look those images as animating(motion to the duck) images , for that i had written code something like this

    Qt Code:
    1. class scene : public QGraphicsScene
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. scene()
    7. { QTimer *timer = new QTimer;
    8. connect(timer, SIGNAL(timeout()), this , SLOT(change()));
    9. timer->start(20000);
    10. }
    11.  
    12. public slots:
    13. void change()
    14. {
    15. if(i==0)
    16. {
    17. QImage image("/home/sudheer/scrap/wallpapers/earlymick5.gif");
    18. QPixmap photo(QPixmap::fromImage(image));
    19. addPixmap(photo);
    20. i=1;
    21. }
    22.  
    23. else
    24. {
    25. QImage image("/home/sudheer/scrap/wallpapers/latemick.gif");
    26. QPixmap photo(QPixmap::fromImage(image));
    27. addPixmap(photo);
    28. i=0;
    29. }
    30.  
    31. }
    32. public:
    33. int i;
    34.  
    35. };
    36.  
    37. int main(int argc, char *argv[])
    38. {
    39.  
    40. QApplication app(argc,argv);
    41.  
    42. scene *scene1 = new scene;
    43. scene1->setSceneRect(-200, -200, 600, 600);
    44. QGraphicsView *view = new QGraphicsView(scene1);
    45.  
    46. view->setRenderHint(QPainter::Antialiasing);
    47. view->setBackgroundBrush(QColor(230, 200, 167));
    48. view->setWindowTitle("Graphics testing");
    49. view->show();
    50.  
    51. return app.exec();
    52. }
    To copy to clipboard, switch view to plain text mode 


    but while making of this project , it giving error as


    g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.3.2/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.3.2/include/QtCore -I/usr/local/Trolltech/Qt-4.3.2/include/QtCore -I/usr/local/Trolltech/Qt-4.3.2/include/QtGui -I/usr/local/Trolltech/Qt-4.3.2/include/QtGui -I/usr/local/Trolltech/Qt-4.3.2/include -I. -I. -I. -o main.o main.cpp
    g++ -Wl,-rpath,/usr/local/Trolltech/Qt-4.3.2/lib -o test18 main.o -L/usr/local/Trolltech/Qt-4.3.2/lib -lQtGui -L/usr/local/Trolltech/Qt-4.3.2/lib -L/usr/X11R6/lib -lpng -lSM -lICE -pthread -pthread -lXi -lXrender -lXrandr -lXfixes -lXcursor -lXinerama -lfreetype -lfontconfig -lXext -lX11 -lQtCore -lz -lm -pthread -lgthread-2.0 -lglib-2.0 -lrt -ldl -lpthread
    main.o(.text+0x3e): In function `main':
    : undefined reference to `vtable for scene'
    collect2: ld returned 1 exit status
    make: *** [test18] Error 1

    so plz give me any suggestions
    Last edited by wysota; 28th January 2008 at 12:54. Reason: missing [code] tags

  2. #2
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: animting images

    scene() is a Qt function. That may cause problem
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  3. #3
    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: animting images

    Add #include "main.moc" at the end of your main.cpp, re-run qmake and make.
    J-P Nurmi

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

    sudheer (28th January 2008)

  5. #4
    Join Date
    Nov 2007
    Posts
    42
    Thanks
    11
    Qt products
    Qt4
    Platforms
    Unix/X11

    Smile Re: animting images

    thankq very much,
    but may i know why we ne need to include "main.moc"

  6. #5
    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: animting images

    A tool called moc needs to be run on classes that contain Q_OBJECT macro. Class declarations should be placed in header files, qmake searches only header files by default. Otherwise you must trigger it by hand by including the .moc file.
    J-P Nurmi

Similar Threads

  1. Release build fails to find some resource images
    By MrGarbage in forum Installation and Deployment
    Replies: 3
    Last Post: 8th December 2007, 16:04
  2. Displaying real time images
    By Sheetal in forum Qt Programming
    Replies: 9
    Last Post: 22nd February 2007, 11:29
  3. How to display images in QTextBrowser ?
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 12th January 2007, 08:58
  4. JPEG Images not shown in QiconView using QT3??
    By darpan in forum Qt Programming
    Replies: 1
    Last Post: 4th August 2006, 20:34
  5. working with images
    By Kapil in forum Newbie
    Replies: 2
    Last Post: 9th March 2006, 11:59

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
  •  
Qt is a trademark of The Qt Company.