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. [SOLVED] Overloading QUrl
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Overloading QUrl

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.5k 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.
  • M Offline
    M Offline
    Max13
    wrote on last edited by
    #1

    Hello everybody !

    I'm currently a REST Manager library, and to make things easier for me, I need to overload QUrl::encodedQuery(), I want it to be static and take 1 parameter.

    I've overloaded it in my hpp (outside my class, but inside #ifndef/#endif), and the correct definition in the cpp, but I got errors. (I tried with the static keyword because I want it to be static, but I have more errors, so I'm trying without first)
    Here is the hpp then cpp:
    @QByteArray QUrl::encodedQuery(MXRequestManager::MXEncodedPairList const& params) const;@
    @QByteArray QUrl::encodedQuery(MXRequestManager::MXEncodedPairList const& params) const
    {
    [...]
    }@

    Errors on compile:
    @MXRequestManager.hpp:413: error: prototype for 'QByteArray QUrl::encodedQuery(const QList<QPair<QByteArray, QByteArray> >&) const' does not match any in class 'QUrl'
    ../../../QtSDK/Desktop/Qt/4.8.1/gcc/include/QtCore/qurl.h:155: error: candidate is: QByteArray QUrl::encodedQuery() const
    MXRequestManager.hpp:413: error: declaration of 'QByteArray QUrl::encodedQuery(const QList<QPair<QByteArray, QByteArray> >&) const' outside of class is not definition@

    Maybe it's not working like operators overloads... Is there a way to do it without subclassing QUrl ?
    Thanks for your help.

    We all have started by asking questions. Then after some time, we can begin answering them.

    1 Reply Last reply
    0
    • _ Offline
      _ Offline
      _rmn
      wrote on last edited by
      #2

      Without subclassing you can make function, that takes QUrl as parameter:
      @
      QByteArray encodedQuery(const QUrl &url, MXRequestManager::MXEncodedPairList const &params)
      {
      [...]
      }
      @

      Otherwise you need to inherit from QUrl and add your methods.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Max13
        wrote on last edited by
        #3

        Ok, it's what I thought about.

        I've never tried, but I thought that I could overload like an operator... But after thinking a little bit...

        Thank you for your help.

        We all have started by asking questions. Then after some time, we can begin answering them.

        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