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

QUrl non-class type



  • Compiling ok:
    @QUrl u;
    u.setHost("127.0.0.1");@

    @QUrl u("");
    u.setHost("127.0.0.1");@

    Compile error:
    @QUrl u();
    u.setHost("127.0.0.1");@

    request for member 'setHost' in 'u', which is of non-class type 'QUrl()'

    What is wrong with this?


  • Moderators

    Syntax is incorrect. This should not work for all C++ classes, not only Qt classes.

    You need to use the parentheses only when you specify any arguments do an assignment like this:
    @
    QUrl u;
    ...
    u = QUrl();
    @


Log in to reply