PDA

View Full Version : How to use QGraphicsView?



xleniz
7th June 2012, 18:25
I'm trying to get QGraphicsView and QGraphicsScene work (in one file), but it doesnt. Dont laugh, im beginner:D



#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QWidget>
#include <QGraphicsView>

class graphics : QGraphicsScene {
Q_OBJECT;
public:
graphics(QWidget* parent = 0);
};

graphics::graphics(QWidget * parent) : QGraphicsScene {
QGraphicsView view(this);
}

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
graphics Graphics;
Graphics.show();
return app.exec();
}


Oh and if you have a tutorial it would be great.. I googled for 15 min.

Added after 11 minutes:

Np fixed it!!

wysota
7th June 2012, 20:10
The problem is solvable by adding #include "main.moc" before the main function and reruning qmake.