Results 1 to 3 of 3

Thread: how can i initilize a qvector like this ?

  1. #1
    Join Date
    Feb 2009
    Location
    Clermont-Ferrand, France
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default how can i initilize a qvector like this ?

    QVector<QString> = {"ab","cd","ef","gg"}

    is there a way to do thing similar like this ?

    since using append involves too much typing when the Vector is large

    thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how can i initilize a qvector like this ?

    You can write:
    Qt Code:
    1. QVector<QString> = QVector<QString>() << "ab" << "cd" << "ef" << "gg";
    To copy to clipboard, switch view to plain text mode 
    But I would suggest using QStringList instead.
    J-P Nurmi

  3. #3
    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: how can i initilize a qvector like this ?

    Quote Originally Posted by elflord View Post
    QVector<QString> = {"ab","cd","ef","gg"}

    is there a way to do thing similar like this ?

    since using append involves too much typing when the Vector is large

    thanks
    At this point there is no way to do this. I know that new C++ standard will make it possible, but just with regular vectors. After that i think qt will have this.
    I'm a rebel in the S.D.G.

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.