Could someone please point me to a very simple QGraphicsView Example for QT5.7 QtCreator mainwindow's main.cpp that actually works and doesn't throw a "no matching function for call" error.
I've read the documentation for QGraphicsView, QGraphicsScene, and QGraphicsItem. I've tried various code published here and elsewhere which is supposed to work. But everything seems to throw that error.
For example, I start a new Qt widgets application in Qt Creator. I change nothing except main.cpp, which becomes:
#include "mainwindow.h"
#include <QApplication>
#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QGraphicsView>
int main( int argc, char **argv )
{
// item == rect
view.show();
return app.exec();
}
#include "mainwindow.h"
#include <QApplication>
#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QGraphicsView>
int main( int argc, char **argv )
{
QApplication app(argc, argv);
QGraphicsScene scene;
QGraphicsRectItem *rect = scene.addRect(QRectF(0, 0, 100, 100));
QGraphicsItem *item = scene.itemAt(50, 50);
// item == rect
QGraphicsView view(&scene);
view.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
At the line:
QGraphicsItem *item = scene.itemAt(50, 50);
To copy to clipboard, switch view to plain text mode
I get "no matching function for call to 'QGraphicsScene::itemAt(int,int)'.
Bookmarks