I been trying and trying to get this to work but it just refuses to work. I read the QT documentation and I'm just unable to get the insert function to function. When I build I get the following complication errors
/home/mmanley/projects/StreamDesk/libstreamdesk/SDDatabase.cpp: In constructor 'SDDatabase::SDDatabase()':
/home/mmanley/projects/StreamDesk/libstreamdesk/SDDatabase.cpp:27:44: error: no matching function for call to 'QHash<QString, SDChatEmbed>::insert(const char [9], SDChatEmbed (&)())'
/usr/include/qt4/QtCore/qhash.h:751:52: note: candidate is: QHash<Key, T>::iterator QHash<Key, T>::insert(const Key&, const T&) [with Key = QString, T = SDChatEmbed]
make[2]: *** [libstreamdesk/CMakeFiles/streamdesk.dir/SDDatabase.cpp.o] Error 1
make[1]: *** [libstreamdesk/CMakeFiles/streamdesk.dir/all] Error 2
here is the header file:
class SDStreamEmbed {
Q_OBJECT
public:
SDStreamEmbed();
SDStreamEmbed(const SDStreamEmbed &other);
QString FriendlyName() const;
SDStreamEmbed &operator=(const SDStreamEmbed &other) {return *this;}
bool operator==(const SDStreamEmbed &other) const {return friendlyName == other.friendlyName;}
private:
QString friendlyName;
};
Q_DECLARE_METATYPE(SDStreamEmbed)
inline uint qHash(const SDStreamEmbed &key) {
return qHash(key.FriendlyName());
}
and the implementation
SDStreamEmbed::SDStreamEmbed() {
}
SDStreamEmbed::SDStreamEmbed(const SDStreamEmbed& other) {
}
QString SDStreamEmbed::FriendlyName() const {
return friendlyName;
}
and how I am invoking it
SDChatEmbed embedTest();
ChatEmbeds.insert("DemoTest", embedTest);
and the definition of ChatEmbeds
QHash<QString, SDStreamEmbed> StreamEmbeds;