Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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



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



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



  • 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.



  • [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.


Log in to reply