PDA

View Full Version : qt4 to qt5 ... ReplaceText ambiguous



JoZCaVaLLo
26th June 2013, 16:49
Hello!

I'm porting my code from qt4 to qt5.

I have a function myClass::ReplaceText(QString, QString) that under qt4 compiles ok, but under qt5 get ambiguous with


WINCOMMDLGAPI HWND APIENTRY ReplaceTextW(LPFINDREPLACEW);
#ifdef UNICODE
#define ReplaceText ReplaceTextW

and I get the following error:
'ReplaceTextW' : is not a member of 'myClass'


Does anybody know why?

Thanks

wysota
27th June 2013, 00:06
I don't think Qt has anything to do with this.

ChrisW67
27th June 2013, 03:17
It's happening because everywhere the C pre-processor sees ReplaceText it is substituting ReplaceTextW (exactly as requested) making your code:


whatever myClass::ReplaceText(QString, QString)
// read
whatever myClass::ReplaceTextW(QString, QString)

which the compiler points out is not correct. I cannot see how changing Qt version would change this, but changing/including Windows API headers in your source, changing compilers or changing Windows SDK certainly can (that's where the define comes from).

Assuming you do not actually use the Windows API ReplaceText function you could follow your Windows API includes with:


#include <windows.h>
#undef ReplaceText

or rename your function.