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. Operator+ with chars*
Forum Updated to NodeBB v4.3 + New Features

Operator+ with chars*

Scheduled Pinned Locked Moved General and Desktop
8 Posts 5 Posters 1.9k 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.
  • S Offline
    S Offline
    spode
    wrote on last edited by
    #1

    How to do this?

    @
    QString("hello " +
    "newbie!");
    @

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Smar
      wrote on last edited by
      #2

      For example @QString foo = "bar" + "desu";@
      or @QString("%1%2").arg("str", "another");@

      1 Reply Last reply
      0
      • S Offline
        S Offline
        spode
        wrote on last edited by
        #3

        Thanks but this is not what I wanted: I wanted to use that form as in c# because it is cleaner to read.

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

          Cleaner to read or not (it's subjective), this isn't C#.

          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
          • S Offline
            S Offline
            spode
            wrote on last edited by
            #5

            no way so?

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dangelog
              wrote on last edited by
              #6

              @
              QString("hello " "newbie");
              @

              :-)

              Software Engineer
              KDAB (UK) Ltd., a KDAB Group company

              1 Reply Last reply
              0
              • T Offline
                T Offline
                twsimpson
                wrote on last edited by
                #7

                In C++, you can only overload binary operators if, at least one of the types is a non primitive type. So, as pointers are primitive, you can't use the + operator on (const char*, const char*)

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  spode
                  wrote on last edited by
                  #8

                  0k. thank you!

                  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