Results 1 to 6 of 6

Thread: cannot convert parameter 2 from 'char [80]' to 'LPWSTR'

  1. #1
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default cannot convert parameter 2 from 'char [80]' to 'LPWSTR'

    Hi,
    I am using QT-4.3 and Using Visual Studio-2005 for compiling. I need to find the Web camera in windows. For that I use this command,

    Qt Code:
    1. char szDeviceName[80];
    2. char szDeviceVersion[80];
    3.  
    4. for(int iPos = 0; iPos<2; iPos++)
    5. {
    6. if (capGetDriverDescription( iPos, szDeviceName, sizeof (szDeviceName),
    7. szDeviceVersion,
    8. sizeof (szDeviceVersion)
    9. ))
    10.  
    11. qDebug()<< " driverName " << driverName;
    12. }
    To copy to clipboard, switch view to plain text mode 
    when I try this, at the time of compiling VS-2005 display an error like this,

    'capGetDriverDescriptionW' : cannot convert parameter 2 from 'char [80]' to 'LPWSTR'
    Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

    Please help me to solve this probs
    Last edited by marcel; 4th December 2007 at 08:43. Reason: Added code tags.

  2. #2
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: cannot convert parameter 2 from 'char [80]' to 'LPWSTR'

    Why don't you use QString, if you are working with Qt?
    Qt 5.3 Opensource & Creator 3.1.2

  3. #3
    Join Date
    Jul 2007
    Posts
    166
    Thanks
    25
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: cannot convert parameter 2 from 'char [80]' to 'LPWSTR'

    Hi,
    When I use QString, then the error display like this,

    'capGetDriverDescriptionW' : cannot convert parameter 2 from 'QString' to 'LPWSTR'

    Please Help me

  4. #4
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: cannot convert parameter 2 from 'char [80]' to 'LPWSTR'

    So, I think (I am not that good in MFC programming), but LPWSTR is long pointer to wide string. You are trying to convert a string to pointer, which is not possible. Try to:
    Qt Code:
    1. char szDeviceName[80];
    2. char szDeviceVersion[80];
    To copy to clipboard, switch view to plain text mode 
    change to

    Qt Code:
    1. char* szDeviceName;
    2. char* szDeviceVersion;
    To copy to clipboard, switch view to plain text mode 

    Take a look at
    http://forums.microsoft.com/MSDN/Sho...14603&SiteID=1
    Last edited by MarkoSan; 4th December 2007 at 06:05.
    Qt 5.3 Opensource & Creator 3.1.2

  5. #5
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: cannot convert parameter 2 from 'char [80]' to 'LPWSTR'

    As we're in an unicode environment you have to use WCHAR instead char.
    or QString with .utf16()

  6. #6
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: cannot convert parameter 2 from 'char [80]' to 'LPWSTR'

    or call capGetDriverDescriptionA explicitly...

Similar Threads

  1. unable to save QCStrings properly in a buffer
    By nass in forum Qt Programming
    Replies: 13
    Last Post: 15th November 2006, 20:49

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.