Results 1 to 3 of 3

Thread: qt4 to qt5 ... ReplaceText ambiguous

  1. #1
    Join Date
    Jun 2009
    Posts
    37
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default qt4 to qt5 ... ReplaceText ambiguous

    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

    Qt Code:
    1. WINCOMMDLGAPI HWND APIENTRY ReplaceTextW(LPFINDREPLACEW);
    2. #ifdef UNICODE
    3. #define ReplaceText ReplaceTextW
    To copy to clipboard, switch view to plain text mode 

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


    Does anybody know why?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qt4 to qt5 ... ReplaceText ambiguous

    I don't think Qt has anything to do with this.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,594
    Thanks
    13
    Thanked 1,587 Times in 1,516 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: qt4 to qt5 ... ReplaceText ambiguous

    It's happening because everywhere the C pre-processor sees ReplaceText it is substituting ReplaceTextW (exactly as requested) making your code:
    Qt Code:
    1. whatever myClass::ReplaceText(QString, QString)
    2. // read
    3. whatever myClass::ReplaceTextW(QString, QString)
    To copy to clipboard, switch view to plain text mode 
    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:
    Qt Code:
    1. #include <windows.h>
    2. #undef ReplaceText
    To copy to clipboard, switch view to plain text mode 
    or rename your function.

Similar Threads

  1. Ambiguous shortcut overload
    By QT8seven in forum Newbie
    Replies: 1
    Last Post: 21st December 2011, 22:51
  2. Replies: 3
    Last Post: 16th November 2011, 05:06
  3. Rquest for member show() is ambiguous
    By Anshuman in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2011, 14:16
  4. ambiguous documentation and behavior of QTcpSocket
    By moviemax in forum General Programming
    Replies: 1
    Last Post: 4th June 2010, 23:11
  5. ambiguous connect()
    By Cruz in forum Qt Programming
    Replies: 2
    Last Post: 27th August 2009, 11:35

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.