Note that there are some explanatory texts on larger screens.

plurals
  1. POConversion of std::wstring to QString throws linker error
    primarykey
    data
    text
    <p>Hi I need to convert a <code>std::wstring</code> to <code>QString</code> and I tried the most obvious way of </p> <pre><code>std::wstring wideString; QString qtString = QString::fromStdWString(wideString); </code></pre> <p>I got the error:</p> <blockquote> <p>Error 2 error LNK2019: unresolved external symbol <code>"__declspec(dllimport) public: static class QString __cdecl QString::fromStdWString(class std::basic_string&lt;wchar_t,struct std::char_traits&lt;wchar_t&gt;,class std::allocator&lt;wchar_t&gt; &gt; const &amp;)" (__imp_?fromStdWString@QString@@SA?AV1@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z)</code></p> <p>referenced in function <code>"public: void __thiscall FileHandler::deleteDir(class std::basic_string&lt;wchar_t,struct std::char_traits&lt;wchar_t&gt;,class std::allocator&lt;wchar_t&gt; &gt;&amp;,int,unsigned int,bool,bool)" (?deleteDir@FileHandler@@QAEXAAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@HI_N1@Z)</code> filehandler.obj</p> <p>Error 3 fatal error LNK1120: 1 unresolved externals C:\Users\Documents\Visual Studio 2008\Projects\product_dev\deletefiles\Debug\FileHandler.exe</p> </blockquote> <p>I also tried using the method <code>QString::fromWCharArray</code>:</p> <pre><code>qstring temp = QString::fromWCharArray(const_cast&lt;wchar_t*&gt;(wideString.c_str()),wideString.size()); </code></pre> <p>The error I get is </p> <blockquote> <p>Error 2 error LNK2019: unresolved external symbol <code>"__declspec(dllimport) public: static class QString __cdecl QString::fromWCharArray(wchar_t const*,int)" (__imp_?fromWCharArray@QString@@SA?AV1@PB_WH@Z)</code></p> <p>referenced in function <code>"public: void __thiscall FileHandler::deleteDir(class std::basic_string&lt;wchar_t,struct std::char_traits&lt;wchar_t&gt;,class std::allocator&lt;wchar_t&gt; &gt;&amp;,int,unsigned int,bool,bool)" (?deleteDir@FileHandler@@QAEXAAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@HI_N1@Z)</code> filehandler.obj</p> <p>Error 3 fatal error LNK1120: 1 unresolved externals C:\Users\Documents\Visual Studio 2008\Projects\product_dev\deletefiles\Debug\FileHandler.exe 1</p> </blockquote> <p>How do I proceed to resolve this issue?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload