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
{
Q_OBJECT
public:
scene()
connect(timer, SIGNAL(timeout()), this , SLOT(change()));
timer->start(20000);
}
public slots:
void change()
{
if(i==0)
{
QImage image
("/home/sudheer/scrap/wallpapers/earlymick5.gif");
addPixmap(photo);
i=1;
}
else
{
QImage image
("/home/sudheer/scrap/wallpapers/latemick.gif");
addPixmap(photo);
i=0;
}
}
public:
int i;
};
int main(int argc, char *argv[])
{
scene *scene1 = new scene;
scene1->setSceneRect(-200, -200, 600, 600);
view
->setRenderHint
(QPainter::Antialiasing);
view
->setBackgroundBrush
(QColor(230,
200,
167));
view->setWindowTitle("Graphics testing");
view->show();
return app.exec();
}
class scene : public QGraphicsScene
{
Q_OBJECT
public:
scene()
{ QTimer *timer = new QTimer;
connect(timer, SIGNAL(timeout()), this , SLOT(change()));
timer->start(20000);
}
public slots:
void change()
{
if(i==0)
{
QImage image("/home/sudheer/scrap/wallpapers/earlymick5.gif");
QPixmap photo(QPixmap::fromImage(image));
addPixmap(photo);
i=1;
}
else
{
QImage image("/home/sudheer/scrap/wallpapers/latemick.gif");
QPixmap photo(QPixmap::fromImage(image));
addPixmap(photo);
i=0;
}
}
public:
int i;
};
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
scene *scene1 = new scene;
scene1->setSceneRect(-200, -200, 600, 600);
QGraphicsView *view = new QGraphicsView(scene1);
view->setRenderHint(QPainter::Antialiasing);
view->setBackgroundBrush(QColor(230, 200, 167));
view->setWindowTitle("Graphics testing");
view->show();
return app.exec();
}
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
Bookmarks