There is a QList member variable named m_noteList
containing QSharedPointer elements of class Note
.
private:
QList< QSharedPointer<Note> > m_noteList;
If a new note is created, its reference is appended to the list:
void Traymenu::newNote(){
QSharedPointer<Note> note(new Note(this));
m_noteList << note;
}
For each Note-element, whichs pointers are in m_noteList, I want to get its title and add it to my contextmenu. Purpose is to click on that title to open the note:
for ( int i = 0 ; i < m_noteList.count() ; i++ ) {
std::string menuEntryName = m_noteList[i].getTitle();
QAction *openNote = m_mainContextMenu.addAction(menuEntryName);
}
I get an error
C:\project\traymenu.cpp:43: Fehler: 'class QSharedPointer<Note>' has no member named 'getTitle'
std::string menuEntryName = &m_noteList[i].getTitle();
^
Basically I want to get access to the objects that are referenced in the m_noteList
. How do I do that? I thought with m_noteList[i]
to get access to that element, but obviously the compiler expects something of type QSharedPointer
. Why?