Results 1 to 2 of 2

Thread: QMap QList

  1. #1
    Join Date
    Feb 2011
    Posts
    4
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Question QMap QList

    hi everyone
    I'm new to Qt

    look at this code:
    Qt Code:
    1. int node1;
    2. QMap< int,QList<int> > map;
    3. QList<int> adjacent = map.values(node1);
    To copy to clipboard, switch view to plain text mode 

    when i run it: boom
    error: conversion from 'QList<QList<int> >' to non-scalar type 'QList<int>' requested

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QMap QList

    Look at the documentation: QMap::values() returns a QList of T's (in your case T is a QList<int>)

    So you need to decide if you really need a QMap<int, QList<int> > then values(...) returns a QList<QList<int> > or use the value(...) member function to return a QList<int>

  3. The following user says thank you to Zlatomir for this useful post:

    dare5421 (24th March 2011)

Similar Threads

  1. How to view data stored in Qmap or QList
    By sankar in forum Newbie
    Replies: 6
    Last Post: 17th February 2011, 09:30
  2. Replies: 1
    Last Post: 25th June 2010, 13:17
  3. Replies: 0
    Last Post: 25th June 2009, 08:17
  4. QMap in QList ?
    By npc in forum Newbie
    Replies: 2
    Last Post: 5th February 2007, 11:51

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.