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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.