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

What am I doing wrong?



  • So, coding is an on-and-off thing for me.
    I've had to reimage my laptop several times over the last year.

    I'm running Qt Creator 4.9.0 based on Qt 5.12.2
    The book I am working from is Blanchett and Summerfield "C++ GUI Programming with Qt 4."

    I realise that the code in the book will not work correctly with the latest Qt without some changes.
    So, I have a copy of the code that some gentleman (whose name escapes me) has written to account for Qt 5 changes.
    The last time I was coding, this all worked well, and I was coding away fine with the updated code.

    That was a few months ago.
    Now, here's the rub - I was getting back to working through the book and opened some basic, easy stuff from the updated code samples, and Qt has it lit up like a Christmas tree with warning and errors.

    So, has something changed in the newest version that I've installed (when I've reimaged my laptop, I downloaded the latest version of Qt Creator) or is the a setting that has bumped to "Compile using something-or-other mode" etc (as packages like this often tend to have?

    A hint, anyone?

    Regards,

    Uberlinc.



  • Okay, so edit: I scrubbed all versions and simply re-copied the plain, original code from the Qt5 files and it did not light up all the errors as it did (possibly a typo somewhere critical which upset the whole thing) but it is still giving a warning:

    "zero as null-pointer constant" after line stating:

    FindDialog(QWidget *parent = 0);

    Is this valid and why would there be a warning?

    Many thanks,

    Uberlinc.


  • Moderators

    C++11 introduced a nullptr keyword that should be used for, well, null pointers. 0 will still work but the warning is there to suggest you modernize. The example is simply pre C++11 code so it will give you that warning with newer compiler. You can ignore it or change it to

    FindDialog(QWidget *parent = nullptr);
    

    It will work the same either way.



  • That's as comprehensive an answer as I could have expected!
    Many thanks!


Log in to reply