Results 1 to 3 of 3

Thread: Token in QString

  1. #1
    Join Date
    Feb 2014
    Posts
    13
    Thanks
    1
    Qt products
    Qt5

    Default Token in QString

    Let

    Qt Code:
    1. this.is.a.string
    To copy to clipboard, switch view to plain text mode 

    a QString. Is there a QString method that returns me the nth token based on a separator character? Something in the form

    Qt Code:
    1. method(QString,1,46) return "this"
    To copy to clipboard, switch view to plain text mode 

    The separator character in this case is the dot
    Last edited by Imhotep; 6th November 2020 at 20:11.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Token in QString

    Quote Originally Posted by Imhotep View Post
    Is there a QString method that returns me the nth token based on a separator character?
    Yes, QString::section().

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Token in QString

    Or QString::split(), using '.' as the split delimiter if you want all of the pieces.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 2
    Last Post: 11th August 2011, 16:42
  2. How to split the char* with the token??
    By Gokulnathvc in forum Newbie
    Replies: 1
    Last Post: 15th April 2011, 13:13
  3. expected `)' before '*' token
    By vinod sharma in forum Qt Programming
    Replies: 3
    Last Post: 15th March 2010, 08:57
  4. expected initializer before »)« token
    By Holy in forum Qt Programming
    Replies: 2
    Last Post: 24th May 2008, 17:24
  5. setVisible, -> token, problems
    By Salazaar in forum Newbie
    Replies: 25
    Last Post: 12th June 2007, 15:30

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.