Results 1 to 4 of 4

Thread: How know if Qt is running on a Desktop

  1. #1
    Join Date
    Dec 2009
    Posts
    62
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default How know if Qt is running on a Desktop

    Hi

    I wonder if there is a compiler switch to know if Qt is Qt is running in a Desktop environment like Win32, OS-X etc. I am developing an app that should run on Win32 / Windows Mobile and Symbian and in some scenarios I want to do showMaximized on a QDialog when in Windows Mobile or Symbian but not when the application is running on Win32. The rest of the code will be the same for all platforms, only how my derived QDialog is shown

  2. #2
    Join Date
    Dec 2009
    Posts
    128
    Thanks
    7
    Thanked 14 Times in 14 Posts
    Platforms
    Unix/X11 Windows

    Default Re: How know if Qt is running on a Desktop

    If you compile your app for those systems you probably have environment variables like _WIN32 to make the difference at compile time. Now, you could use it like this :

    Qt Code:
    1. QDialog myDialog ;
    2.  
    3. #ifndef _WIN32
    4. myDialog.showMaximized() ;
    5. #else
    6. myDialog.show() ;
    7. #endif
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Dec 2009
    Posts
    62
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How know if Qt is running on a Desktop

    Thanks this is all great, I just wondered if there is a way to not limit it to Windows incase I want to move to Mac in the future this will not work all the way or do I have to use a combination of platform specific switches.

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How know if Qt is running on a Desktop

    It'll be a combination of platform specific switches.

  5. The following user says thank you to squidge for this useful post:

    hubbobubbo (28th April 2010)

Similar Threads

  1. Desktop using QT
    By QT-embedded in forum Newbie
    Replies: 9
    Last Post: 26th April 2010, 13:47
  2. Desktop dir
    By TomASS in forum Newbie
    Replies: 1
    Last Post: 8th November 2009, 13:22
  3. Replies: 5
    Last Post: 31st January 2009, 07:36
  4. Which Virtual Desktop am I running on?
    By onamatic in forum Qt Programming
    Replies: 0
    Last Post: 24th November 2008, 17:04
  5. Replies: 1
    Last Post: 17th May 2006, 00:23

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.