Skip to content

Instantly share code, notes, and snippets.

@mitchcurtis
Created January 13, 2016 16:04
Show Gist options
  • Save mitchcurtis/8526eb7155c589166087 to your computer and use it in GitHub Desktop.
Save mitchcurtis/8526eb7155c589166087 to your computer and use it in GitHub Desktop.
Custom QGraphicsRectItem
#include <QtWidgets>
class RectItem : public QGraphicsRectItem
{
public:
RectItem()
{
setRect(0, 0, 40, 40);
}
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QGraphicsView view;
QGraphicsScene *scene = new QGraphicsScene(&view);
RectItem *rectItem = new RectItem;
scene->addItem(rectItem);
view.setScene(scene);
view.resize(400, 400);
view.show();
return app.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment