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. constructing a string using temporaries
Forum Updated to NodeBB v4.3 + New Features

constructing a string using temporaries

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 175 Views 1 Watching
  • 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.
  • U Offline
    U Offline
    user4592357
    wrote on last edited by
    #1

    i need a alike method:

    QString constructWidgetTitle(const QString &sPrefix, const QString &sWidgetTitle)
    {
    	return sPrefix + "_" + sWidgetTitle;
    }
    

    is this the correct way to do it? or i should use QLatin1String (or what?) for constructing the "_"?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      The above is correct (unless you disabled this feature in your project file), using return sPrefix + QLatin1String("_") + sWidgetTitle;, however, is more efficient.

      If you have a lot of +s then the best solution is to #include <QStringBuilder> and use % instead of +

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      2

      • Login

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