【发布时间】:2010-10-22 05:38:39
【问题描述】:
我无法在我的 Qt 应用程序中使用函数 MonitorFromPoint。我在 Windows XP 上有带有 mingw 的最新 Qt SDL 2010.05
#include <QtCore/QCoreApplication>
#include<windows.h>
#include <winuser.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
POINT pt;
MonitorFromPoint(pt,2);
return a.exec();
}
我将此添加到 .pro 文件中
LIBS+= -luser32
结果是
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"..\include\QtCore" -I"..\include" -I"..\include\ActiveQt" -I"tmp\moc\debug_shared" -I"..\testUser32" -I"." -I"..\mkspecs\win32-g++" -o tmp\obj\debug_shared\main.o ..\testUser32\main.cpp
mingw32-make[1]: Leaving directory `C:/Qt/2010.05/qt/testUser32-build-desktop'
mingw32-make: Leaving directory `C:/Qt/2010.05/qt/testUser32-build-desktop'
..\testUser32\main.cpp: In function 'int main(int, char**)':
..\testUser32\main.cpp:8: error: 'MonitorFromPoint' was not declared in this scope
mingw32-make[1]: *** [tmp/obj/debug_shared/main.o] Error 1
mingw32-make: *** [debug-all] Error 2
The process "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited with code %2.
Error while building project testUser32 (target: Desktop)
When executing build step 'Make'
IRc 上有人说这是一个 mingw 问题,我应该使用 visualc 编译器。切换编译器需要时间,也许我会发现其他问题。我从wingdi.h 导入了函数,没有任何问题。 我需要更好地解释这个问题,你如何解决它和解决方案
附:我正在尝试在多显示器系统中获取屏幕几何图形,QDesktopWidget 不起作用,请参阅主题Capture multiple screens desktop image using Qt4
【问题讨论】:
-
我不确定我的评论会有多有趣。但是,您可以手动包含函数 signature.LOL,尽管它不是永久性的补救措施。但它应该可以工作。
标签: c++ qt winapi linker mingw