开发者

Qt error while including <windows.h>

开发者 https://www.devze.com 2023-01-20 09:51 出处:网络
How can I use windows.h in Qt application? After including it I get several errors like c:\\Qt\\4.4.3\\include/QtCore/../../src/corelib/arch/qatomic_windows.h:387: error:

How can I use windows.h in Qt application? After including it I get several errors like

c:\Qt\4.4.3\include/QtCore/../../src/corelib/arch/qatomic_windows.h:387: error:    
declaration of C function 'long int InterlockedCompareExchange(long int*, long int,    
 long int)' conflicts with    
d:\old\mingw\bin\../lib/gcc/mingw32/4.3.3/../../../../include/winbase.h:1681: error:    
previous declaration 'LONG InterlockedCompareExchange(volatile LONG*, LONG,    
 LONG)' here  

All includes in order:

windows.h    
iostream    
QtCore    
QtGui    
QObject    
QString    
QFile    
QProcess    
QIODevice

EDIT: Problem disappear, Process.start() is now work开发者_Python百科ing, but I'm unable to say, what change made the difference.

EDIT2: It's not that simple. I'll create new question.

EDIT3: The same code QProcess Process; Process.start("notepad.exe"); works in main() and doesn't work in function called as a slot. Works only QProcess *Process = new QProcess(); Process->start("notepad.exe");


Its worth debugging why QProcess throws a QProcess::UnknownError - switching to use the native API directly does make the whole point of using QT - its cross platform afterall - a bit of a joke.

You are doing something that should work, that probably uses WinExec or system() already and as such, your attempt to launch notepad will just fail again.

Perhaps QT just needs the full path to notepad.exe? There are definitely times to write platform code in QT, this isn't one of them.


Use proper version of mingw for your version of Qt. Qt 4.3 is not compatible with mingw >= 4

0

精彩评论

暂无评论...
验证码 换一张
取 消