//----------------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------------
#include <QApplication>
#include <QGraphicsView>
#include <QGraphicsRectItem>
#include <QHBoxLayout>
//----------------------------------------------------------------------------
{
public:
MyFooView
(QWidget* parent
= NULL) : {
}
{
scale(20.0, 20.0);
}
~MyFooView(void)
{
}
};
int main(int argv, char **args)
{
scene
->setSceneRect
(QRectF(0,
0,
5000,
5000));
MyFooView* view = new MyFooView(scene);
dummy
->setBrush
(QBrush(Qt
::red));
dummy->setAcceptHoverEvents(true);
scene->addItem(dummy);
view->centerOn(0.0, 0.0);
l->addWidget(view);
w->setLayout(l);
w->show();
return app.exec();
}
//----------------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------------
#include <QApplication>
#include <QGraphicsView>
#include <QGraphicsRectItem>
#include <QHBoxLayout>
//----------------------------------------------------------------------------
class MyFooView : public QGraphicsView
{
public:
MyFooView(QWidget* parent = NULL) :
QGraphicsView(parent)
{
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
}
MyFooView(QGraphicsScene* scene, QWidget* parent = NULL) :
QGraphicsView(scene, parent)
{
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
scale(20.0, 20.0);
}
~MyFooView(void)
{
}
};
int main(int argv, char **args)
{
QApplication app(argv, args);
QGraphicsScene* scene = new QGraphicsScene();
scene->setSceneRect(QRectF(0, 0, 5000, 5000));
MyFooView* view = new MyFooView(scene);
QGraphicsRectItem* dummy = new QGraphicsRectItem(50.0, 50.0, 30.0, 30.0);
dummy->setBrush(QBrush(Qt::red));
dummy->setAcceptHoverEvents(true);
dummy->setFlag(QGraphicsItem::ItemIsSelectable, true);
dummy->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
scene->addItem(dummy);
view->centerOn(0.0, 0.0);
QHBoxLayout* l = new QHBoxLayout;
l->addWidget(view);
QWidget* w = new QWidget();
w->setLayout(l);
w->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks