Results 1 to 6 of 6

Thread: What is the associate type of QList<QPair<double, QString>> in qml?

  1. #1
    Join Date
    Jan 2011
    Posts
    127
    Thanks
    42
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default What is the associate type of QList<QPair<double, QString>> in qml?

    Qt Code:
    1. class whatever: public QObject
    2. {
    3. Q_OBJECT
    4. public:
    5. explicit generalUnitConverter(QObject *parent = nullptr);
    6.  
    7. QList<QPair<double, QString>> do_something();
    8. }
    To copy to clipboard, switch view to plain text mode 

    How could I access the data return by do_something in qml?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: What is the associate type of QList<QPair<double, QString>> in qml?

    There is very likely not exactly matching JavaScript type.

    In which case you'll have to find a better way of presenting the data.
    What is the meaning of those pair values? Does the order of the pairs matter?

    Cheers,
    _

  3. #3
    Join Date
    Jan 2011
    Posts
    127
    Thanks
    42
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: What is the associate type of QList<QPair<double, QString>> in qml?

    Quote Originally Posted by anda_skoa View Post
    There is very likely not exactly matching JavaScript type.

    In which case you'll have to find a better way of presenting the data.
    What is the meaning of those pair values? Does the order of the pairs matter?

    Cheers,
    _
    No, the order is irrelevant.I am parsing the string by c++, the result would be
    double and string, if there are not associate types, then I have to get those values
    back by two functions.
    QList<double> and QList<QString>

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: What is the associate type of QList<QPair<double, QString>> in qml?

    I can see that the result is double and string, but what do they mean?
    Can you given an example?

    Cheers,
    _

  5. #5
    Join Date
    Jan 2011
    Posts
    127
    Thanks
    42
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: What is the associate type of QList<QPair<double, QString>> in qml?

    Quote Originally Posted by anda_skoa View Post
    I can see that the result is double and string, but what do they mean?
    Can you given an example?

    Cheers,
    _
    1 km-->1, "km"

    FFFF-->FFFF, "heximal"

    and so on

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: What is the associate type of QList<QPair<double, QString>> in qml?

    Hmm.

    You could try a QVariantList and have each entry be another QVariantList with two elements.
    Or a QVariantList and each entry a QVariantMap with an entry for "value" and an entry for "unit"

    Cheers,
    _

  7. The following user says thank you to anda_skoa for this useful post:

    stereoMatching (30th December 2013)

Similar Threads

  1. Program not finding an existing double in a QList<double>
    By aarelovich in forum Qt Programming
    Replies: 2
    Last Post: 9th May 2011, 20:59
  2. How to qSort a Qlist of QPair?
    By Trader in forum Qt Programming
    Replies: 2
    Last Post: 7th July 2010, 19:04
  3. Replies: 10
    Last Post: 20th June 2010, 22:29
  4. Replies: 4
    Last Post: 12th October 2009, 19:36
  5. Replies: 7
    Last Post: 16th August 2009, 09:03

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.