Results 1 to 3 of 3

Thread: QVariant, QVariantMap, and QFileInfoList

  1. #1
    Join Date
    Jul 2007
    Location
    New York
    Posts
    45
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default QVariant, QVariantMap, and QFileInfoList

    I am trying to do something like this:

    Qt Code:
    1. QVariantMap payload;
    2. QDir d = "/";
    3. payload["children"] = d.entryInfoList();
    To copy to clipboard, switch view to plain text mode 

    but the compiler doesn't seem to have an 'operator=':

    fileserverWindow.cpp:50: error: no match for 'operator=' in '(+ payload)->QMap<Key, T>::operator[] [with Key = QString, T = QVariant](((const QString&)(& QString(((const char*)"children"))))) = QDir::entryInfoList(QFlags<QDir::Filter>, QFlags<QDir::SortFlag>) const(QFlags<QDir::Filter>(NoFilter), QFlags<QDir::SortFlag>(NoSort))'
    I know that qRegisterMetaType<QFileInfo>("QFileInfo"); goes in there somewhere, plus the Q_DECLARE_METATYPE ( QFileInfo ) but I can't seem to figure out where... no combination works. I think Q_DECLARE_METATYPE ( QFileInfo ) goes at the top, and qRegisterMetaType goes in the function, before the assignment.

    How do I assign QFileInfoList to a QVariant?

  2. #2
    Join Date
    Jul 2007
    Location
    New York
    Posts
    45
    Thanks
    5
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: QVariant, QVariantMap, and QFileInfoList

    I tried this:

    Qt Code:
    1. payload["children"] = qVariantFromValue(d.entryInfoList());
    To copy to clipboard, switch view to plain text mode 

    but then there's an error:

    qmetatype.h:183: error: 'qt_metatype_id' is not a member of 'QMetaTypeId<QFileInfoList>'
    how do I register the type?

  3. #3
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QVariant, QVariantMap, and QFileInfoList

    Have you tried Q_DECLARE_METATYPE ( QFileInfoList ), qRegisterMetaType<QFileInfoList>("QFileInfoList")?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.