I have another question (thanks for this great forum. I hope to give something back when I'm able to):
I have subclassed QGraphicsPixmapItem:
{
Q_OBJECT
public:
};
class Pieceitem: public QGraphicsPixmapItem
{
Q_OBJECT
public:
void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event )
};
To copy to clipboard, switch view to plain text mode
You see I've only reimplemented a virtual function.
Then I try to add some objects of the new class to add to the QGraphicsScene:
Pieceitem *a= new Pieceitem;
b=a; //I can't add a Pieceitem, that's why I thought I let the QGraphicsPixmapItem
//point on the Pieceitem. But this is actually a weird plan and cannot be right...
scene->addItem(b);
Pieceitem *a= new Pieceitem;
QGraphicsPixmapItem *b = new QGraphicsPixmapItem;
b=a; //I can't add a Pieceitem, that's why I thought I let the QGraphicsPixmapItem
//point on the Pieceitem. But this is actually a weird plan and cannot be right...
scene->addItem(b);
To copy to clipboard, switch view to plain text mode
This is the error I get the following error:
mainwindow.cpp: In constructor »MainWindow::MainWindow()«:
mainwindow.
cpp:62: Fehler
: »Pieceitem
*« kann nicht nach »
QGraphicsPixmapItem*« in assignment umgewandelt werden
mainwindow.cpp: In constructor »MainWindow::MainWindow()«:
mainwindow.cpp:62: Fehler: »Pieceitem*« kann nicht nach »QGraphicsPixmapItem*« in assignment umgewandelt werden
To copy to clipboard, switch view to plain text mode
That's actually not a Qt problem, but a big gap at my C++ knowledge 
So I want to reimplement a virtual function of QGraphicsPixmapItem and use the objects of the new class just as I used a normal QGraphicsPixmapItem.
Bookmarks