I'm a bit confused, because I thought QSet could hold structs, but I keep getting an error "c:\QtSDK\Desktop\Qt\4.7.4\mingw\include\QtCore\qh ash.h:880: error: no matching function for call to 'qHash(const NoteStruct&)'"
Here's the struct:
struct NoteStruct
{
float startPosition;
float width;
int velocity;
};
struct NoteStruct
{
float startPosition;
float width;
QGraphicsItem *noteLane;
int velocity;
};
To copy to clipboard, switch view to plain text mode
Here's the offending method:
void SequencerScene::copy()
{
currentlyCopiedNotes.clear();
{
NoteStruct newNote;
newNote.startPosition = note->transform().dx();
newNote.width = note->boundingRect().width();
newNote.noteLane = note->parentItem();
newNote.velocity = static_cast<Note*>(note)->getVelocity();
currentlyCopiedNotes.insert(newNote); // THIS IS THE OFFENDING CODE
}
}
void SequencerScene::copy()
{
currentlyCopiedNotes.clear();
foreach (QGraphicsItem *note, selectedItems())
{
NoteStruct newNote;
newNote.startPosition = note->transform().dx();
newNote.width = note->boundingRect().width();
newNote.noteLane = note->parentItem();
newNote.velocity = static_cast<Note*>(note)->getVelocity();
currentlyCopiedNotes.insert(newNote); // THIS IS THE OFFENDING CODE
}
}
To copy to clipboard, switch view to plain text mode
And here's the declaration of currentlyCopiedNotes (in the header file):
private:
QSet<NoteStruct> currentlyCopiedNotes;
private:
QSet<NoteStruct> currentlyCopiedNotes;
To copy to clipboard, switch view to plain text mode
The reason I'm trying to do this is that I am creating a way to copy notes (QGraphicsItems) in a QGraphicsScene, so that they can be pasted afterwards. The NoteStruct is a struct containing the attributes of the notes.
I'd appreciate some advice... thanks!
Bookmarks