Results 1 to 2 of 2

Thread: cannot convert cont char* to LPCWSTR

  1. #1
    Join Date
    Sep 2014
    Posts
    10
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default cannot convert cont char* to LPCWSTR

    hi, I am stuck with an error in QT compiler however it works fine with VS2010. the error states that
    I have seen other posts related to the same error but non has resolved my problem in QT. I have tried _T,L or TEXT but still not working


    > bq. error: C2664: 'HANDLE
    > LoadImageW(HINSTANCE,LPCWSTR,UINT,int,int,UINT)' : cannot convert
    > argument 2 from 'const char *' to 'LPCWSTR' Types pointed to are
    > unrelated; conversion requires reinterpret_cast, C-style cast or
    > function-style cast


    my code is as below

    Qt Code:
    1. Bitmap::Bitmap(std::string const& file_name) {
    2. bitmap_ = static_cast<HBITMAP>(::LoadImage(0, file_name.c_str(), IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION));
    3. }
    To copy to clipboard, switch view to plain text mode 

    please share if you have any idea to resolve this

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

    Default Re: cannot convert cont char* to LPCWSTR

    Quote Originally Posted by habbas33 View Post
    hi, I am stuck with an error in QT compiler however it works fine with VS2010.
    There is no such thing as "QT compiler".

    Have you tried using LoadImageA instead of LoadImageW?
    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.


Similar Threads

  1. How to convert int to char?
    By Bong.Da.City in forum Newbie
    Replies: 12
    Last Post: 9th January 2015, 20:45
  2. Replies: 4
    Last Post: 30th April 2013, 01:49
  3. How to convert unsigned char[] to char *?
    By Gokulnathvc in forum Newbie
    Replies: 2
    Last Post: 29th April 2011, 09:58
  4. How to convert QString to char *
    By rajeshs in forum Qt Programming
    Replies: 7
    Last Post: 27th September 2007, 11:32
  5. How to convert wchar_t* into char*??
    By shailesh in forum Qt Programming
    Replies: 3
    Last Post: 22nd June 2006, 13:39

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.