尝试在 MFC 应用程序中使用 QSettings 时出错
在 dlg.h 中,我输入以下内容
#include<QSettings>
,编译没有问题 但是当我尝试在 .cpp 中执行操作时,
void dlg::OnBnClickedOk(){
QString qstr("config/Config.ini"); //convert Cstring to QString
QSettings settings(qstr, QSettings::IniFormat); }
出现以下错误:
error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QSettings::~QSettings(void)" (__imp_??1QSettings@@UAE@XZ) referenced in function "public: void __thiscall Dlg::OnBnClickedOk(void)" (?OnBnClickedOk@Dlg@@QAEXXZ)
还有更多与此类似的错误,但太长了,所以我不在这里显示它 我没有直接使用 Qstring 而是从 Cstring 转换的原因是每当我创建 QString 对象时我也会遇到类似的错误 有人知道出了什么问题吗?
in dlg.h, i put the following
#include<QSettings>
it compiles with no problems
but when i try to do the operations in the .cpp
void dlg::OnBnClickedOk(){
QString qstr("config/Config.ini"); //convert Cstring to QString
QSettings settings(qstr, QSettings::IniFormat); }
i got the following errors:
error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QSettings::~QSettings(void)" (__imp_??1QSettings@@UAE@XZ) referenced in function "public: void __thiscall Dlg::OnBnClickedOk(void)" (?OnBnClickedOk@Dlg@@QAEXXZ)
and more of errors similar to this but is too long so i'm not showing it here
the reason why i didnt use Qstring direct but converting from Cstring become whenever i create a QString object i'm getting this similar errors too
anyone know whats wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须告诉链接器在项目设置中或通过将库添加到项目中来包含适当的 Qt 库。您可以通过在解决方案资源管理器中右键单击它,选择“添加”,然后选择“现有项目”,将其添加到您的项目中。
You have to tell the linker to include the appropriate Qt library either in the project settings or by adding the library to the project. You can add it to your project by right click on it in the Solution Explorer, selecting "Add" and then "Existing Item".