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. How to know in code if a QString value is = "" or nothing?
Forum Updated to NodeBB v4.3 + New Features

How to know in code if a QString value is = "" or nothing?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 1.7k 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.
  • M Offline
    M Offline
    MathSquare
    wrote on last edited by
    #1

    How to know in code if a QString value is = "" or nothing?
    @if (MyQStringName == ""){
    }@
    but that doen't work.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Did you try the documentation of [[doc:QString]]? It has many interesting methods, including one called isEmpty() that sounds about right...

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #3

        You are doing an assignment <code>=</code>, not a comparison <code>==</code>.

        Again, do not post your questions in the QnA Testing Area. If you have a general question, like this one, post it the General and Desktop.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          [quote author="MathSquare" date="1359457064"]How to know in code if a QString value is = "" or nothing?
          @
          if (MyQStringName = ""){
          }
          @
          but that doen't work.[/quote]
          Andre's response is certainly complete.
          One additional remark to your code fragment. You have an assignment '=' and not '==' in your if statement. Therefore, your if statement, when used as typed in your post, cannot work.

          Vote the answer(s) that helped you to solve your issue(s)

          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