Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QUrl non-class type
Qt 6.11 is out! See what's new in the release blog

QUrl non-class type

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 854 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Woomla
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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();
      @

      (Z(:^

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved