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

Conditional error



  • I have experienced strange phenomenon from one day.

    This was a simple source that worked well in the past.
    But now it does not work.

       QPushButton *test[2];
       test[0] = new QPushButton;
       qDebug() << "!test[0] =" <<!test[0];
       qDebug() << "!test[1] =" <<!test[1];
    
    
    result :
    !test[0] = false
    !test[1] = false
    

    I want " !test[1] = true " result...
    Is it my fault?
    So what should I do?

    Thanks in advance for your advice.


  • Qt Champions 2017

    @Kycho said in Conditional error:

    QPushButton *test[2];

    This declaration is array of pointers. These two pointers are not initialised with anything. So you don't know what will get initialised. It will have some random value. !<randomvalue> will be always false.

    So result is as per your code.


Log in to reply