Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Alternative to QString::sprintf()
Forum Updated to NodeBB v4.3 + New Features

Alternative to QString::sprintf()

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 3.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kenchan
    wrote on last edited by
    #1

    So Gentlemen,

    How might I do the equivalent of this without using QString::sprintf ?

    sprintf(buf,"%s%d%s",prefix,intval,suffix);
    

    please let me have your ideas.

    Thanks.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      Kenchan, for future reference, please try to open new posts rather than reopening ages-old ones. I'm going to move this question to its own thread for you.

      In your case, you could use something like:
      @
      QString foo = QString("%1%2%3").arg(prefix).arg(intval).arg(suffix);
      @
      or something. Be sure and look at the docs for QString.

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kenchan
        wrote on last edited by
        #3

        OK, sorry about that. I was just searching for stuff and did not notice the date :-(.

        Thanks for your advice. I look into the arg() stuff in more detail.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on last edited by
          #4

          Not a problem. Glad to help! If you have further questions, feel free to ask!

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved