Results 1 to 5 of 5

Thread: concatenate two values

  1. #1
    Join Date
    Jan 2010
    Posts
    28
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default concatenate two values

    hi all,

    please tell me how to make concatenate of two different datatypes

    Qstring str="4";
    unsigned long lg=100001;

    now i want to make the value as lg= 4100001 .(i.e.,"4"+100001)

    Thanks,

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: concatenate two values

    Have a look at the QString documentation, you can convert unsigned long to QString and then concatenate.

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

    zoz (30th May 2010)

  4. #3
    Join Date
    May 2010
    Location
    Algeria
    Posts
    23
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: concatenate two values

    Hi;

    try use the class QVariant.
    Last edited by Naami; 30th May 2010 at 10:33. Reason: updated contents

  5. The following user says thank you to Naami for this useful post:

    zoz (30th May 2010)

  6. #4
    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: concatenate two values

    Or something like this:
    Qt Code:
    1. str.append(QString("%1").arg(lg));
    To copy to clipboard, switch view to plain text mode 

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

    zoz (30th May 2010)

  8. #5
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Thanks
    23
    Thanked 32 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: concatenate two values

    Qt Code:
    1. QString str="4";
    2. unsigned long lg=100001;
    3.  
    4.  
    5. str += QString("%1").arg(lg);
    6. qDebug() << str;
    7. lg=str.toLong();
    8. qDebug()<< lg;
    To copy to clipboard, switch view to plain text mode 

    Voilá
    __________________________________________________
    My projects: calculator MathGraphica ; SuperEpicMegaHero game ; GooglePlay ; bitbucket ; github
    Like my projects ? Buy me a kofi

Similar Threads

  1. Getting the values from xml file
    By Kokos in forum Newbie
    Replies: 1
    Last Post: 6th April 2010, 10:32
  2. Values of a Q3ListView
    By martisho in forum Qt Programming
    Replies: 0
    Last Post: 13th November 2009, 13:21
  3. Concatenate two array elements
    By b1 in forum General Programming
    Replies: 6
    Last Post: 29th October 2007, 20:43
  4. Replies: 1
    Last Post: 29th May 2006, 09:49
  5. how to concatenate .wav files with different frequencies
    By BOMMACANTI in forum Qt Programming
    Replies: 1
    Last Post: 28th May 2006, 13:51

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.