Results 1 to 2 of 2

Thread: How to use Windows API with QT4?

  1. #1
    Join Date
    Mar 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default How to use Windows API with QT4?

    Hi.
    I have an _existing_ MS VC++ application, to where I have to "attach" a GUI, made by QT4.3.3
    I can compile some simple GUIs with VS2005;
    I can compile the existing app (let's say it is "time.exe", and it shows milliseconds on command prompt).
    But I can not combine them together, in one project.
    Here's an example of class in the time.exe which I can't compile from QT4 project:
    Qt Code:
    1. class CTimer
    2. {
    3. public:
    4. CTimer();
    5. ~CTimer();
    6. void Start();
    7. unsigned int GetElapsedTimeMs() const;
    8. unsigned __int64 GetElapsedTimeMks() const;
    9.  
    10. private:
    11. LARGE_INTEGER m_liFreq;
    12. LARGE_INTEGER m_liStart;
    13. LARGE_INTEGER m_liEnd;
    14. };
    To copy to clipboard, switch view to plain text mode 

    implementation:
    Qt Code:
    1. // Timer class
    2. CTimer::CTimer()
    3. {
    4. ::QueryPerformanceFrequency(&m_liFreq);
    5. Start();
    6. }
    7.  
    8. void CTimer::Start()
    9. {
    10. ::QueryPerformanceCounter(&m_liStart);
    11. }
    12.  
    13. unsigned int CTimer::GetElapsedTimeMs() const
    14. {
    15. LARGE_INTEGER liEnd;
    16. ::QueryPerformanceCounter(&liEnd);
    17. return static_cast<unsigned int>((liEnd.QuadPart - m_liStart.QuadPart) * 1000 / m_liFreq.QuadPart);
    18. }
    19.  
    20. unsigned __int64 CTimer::GetElapsedTimeMks() const
    21. {
    22. LARGE_INTEGER liEnd;
    23. ::QueryPerformanceCounter(&liEnd);
    24. return static_cast<unsigned __int64>((liEnd.QuadPart - m_liStart.QuadPart) * 1000000 / m_liFreq.QuadPart);
    25. }
    26.  
    27. // End of the class.
    To copy to clipboard, switch view to plain text mode 

    The QT project itself is very trivial - one button and one editbox, no point to show it here, I guess.

    Example of errors i have if for example "winbase.h" file included:

    Qt Code:
    1. 1>moc_mywidget.cpp
    2. 1>c:\program files\microsoft visual studio 8\vc\platformsdk\include\winbase.h(226) : error C2146: syntax error : missing ';' before identifier 'Internal'
    3. 1>c:\program files\microsoft visual studio 8\vc\platformsdk\include\winbase.h(226) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    To copy to clipboard, switch view to plain text mode 

    If someone could help me, explaining what settings I have to change on VS2005, any path to include, anything what may help, I'd appreciated it so much.
    Thank you.

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

    Default Re: How to use Windows API with QT4?

    It should work out of the box - maybe you forgot to include <windows.h> or something like this?

Similar Threads

  1. Windows not appearing in XP.
    By beardybloke in forum Qt Programming
    Replies: 7
    Last Post: 24th October 2007, 17:32
  2. Deploying with MySQL support under Windows
    By KShots in forum Installation and Deployment
    Replies: 1
    Last Post: 12th October 2006, 09:19
  3. converting unix exe to windows binary
    By deekayt in forum General Programming
    Replies: 2
    Last Post: 17th September 2006, 01:00
  4. Experience using KDevelop with Cygwin under windows
    By high_flyer in forum General Discussion
    Replies: 4
    Last Post: 11th September 2006, 16:50
  5. MDI windows without QWorkspace
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 16th June 2006, 17:15

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
  •  
Qt is a trademark of The Qt Company.