switch/case statement in C++ with a QString type

后端 未结 14 2046
南笙
南笙 2020-12-16 10:19

I want to use switch-case in my program but the compiler gives me this error:

switch expression of type \'QString\' is illegal

How can I us

14条回答
  •  天涯浪人
    2020-12-16 10:46

    I would suggest to use if and break. This would make it near to switch case in the computation.

    QString a="one"
    if (a.contains("one"))
    {
    
       break;
    }
    if (a.contains("two"))
    {
    
       break;
    }
    

提交回复
热议问题