[SOLVED] Overloading QUrl
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.
Without subclassing you can make function, that takes QUrl as parameter:
QByteArray encodedQuery(const QUrl &url, MXRequestManager::MXEncodedPairList const ¶ms)
Otherwise you need to inherit from QUrl and add your methods.
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.