Results 1 to 8 of 8

Thread: "Convert" iterator

  1. #1
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default "Convert" iterator

    Hi,

    it is possible to check and transform an iterator to another type? doesn't seem so, but I wanted to be 100% sure.

    In my case, I have a vector with objects and I'd like to transform the iterator to one of that object.

    For instance:

    Qt Code:
    1. CSQLGroups::VSQLGROUPS vGroups;
    2.  
    3. fillGroups(vGroups);
    4. for(itGr = vGroups.begin(); itGr != vGroups.end(); itGr++)
    5. {
    6. QString name = itGt.sname;
    7. QString surname = itGt.ssurname;
    8.  
    9. if anotherVector.contains(itGr) //But it's an iterator, it's different.
    10. {}
    11. }
    To copy to clipboard, switch view to plain text mode 

    thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: "Convert" iterator

    Try:
    Qt Code:
    1. if(anotherVector.contains(*itGr))
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    jano_alex_es (13th May 2009)

  4. #3
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: "Convert" iterator

    It does when I try with vectors of integers, strings... but it doesn't, logically, when is a non standard type (it can't compare)

    thanks!

  5. #4
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: "Convert" iterator

    how do you declare your vector?
    I'm a rebel in the S.D.G.

  6. #5
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: "Convert" iterator

    it's a group of structs, that's why it's not possible (if I don't reimplement the == operator)

  7. #6
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: "Convert" iterator

    why do you need to reimplement ==? You are not using it in your code.
    I'm a rebel in the S.D.G.

  8. #7
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: "Convert" iterator

    because in the error message said "can't compare " and the compiler stops in the line (not in my code, in the already-built classes) where the code tries to compare the iterator with the struct :P

  9. #8
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: "Convert" iterator

    Yep, got it.
    I'm a rebel in the S.D.G.

Similar Threads

  1. pointer and iterator
    By mickey in forum General Programming
    Replies: 6
    Last Post: 3rd February 2008, 22:24
  2. QLinkedList iterator
    By ^NyAw^ in forum Qt Programming
    Replies: 8
    Last Post: 18th October 2007, 16:15
  3. iterator
    By mickey in forum General Programming
    Replies: 6
    Last Post: 23rd May 2006, 10:28
  4. ::iterator
    By mickey in forum General Programming
    Replies: 2
    Last Post: 20th March 2006, 22:05
  5. convert iterator
    By mickey in forum General Programming
    Replies: 8
    Last Post: 20th March 2006, 21:59

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.