Results 1 to 6 of 6

Thread: Qt version checking at the project-file

  1. #1
    Join Date
    Apr 2008
    Posts
    104
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qt version checking at the project-file

    Hello! How I can to check the Qt version dependency at the .pro-file?
    In the pseudocode, I need something like this:
    Qt Code:
    1. if (QT_VERSION < 4.4)
    2. {
    3. show some message; abort configuration;
    4. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt version checking at the project-file

    read this
    http://doc.trolltech.com/4.4/qmake-v...tml#qt-version
    http://doc.trolltech.com/4.4/qmake-f...ablename-value

    Qt Code:
    1. contains(QT_VERSION, 4.4.1) {
    2. message(4.4.1)
    3. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by spirit; 14th August 2008 at 19:19.

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Qt version checking at the project-file

    This is how we do it in LibQxt project:
    Qt Code:
    1. #check Qt version
    2. QT_VERSION = $$[QT_VERSION]
    3. QT_VERSION = $$split(QT_VERSION, ".")
    4. QT_VER_MAJ = $$member(QT_VERSION, 0)
    5. QT_VER_MIN = $$member(QT_VERSION, 1)
    6.  
    7. lessThan(QT_VER_MAJ, 4) | lessThan(QT_VER_MIN, 2) {
    8. error(LibQxt requires Qt 4.2 or newer but Qt $$[QT_VERSION] was detected.)
    9. }
    To copy to clipboard, switch view to plain text mode 
    It would be nice if there was a built-in version check function in qmake...
    J-P Nurmi

  4. #4
    Join Date
    Apr 2008
    Posts
    104
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt version checking at the project-file

    Thanks a lot!

  5. #5
    Join Date
    Jun 2013
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Qt version checking at the project-file

    Quote Originally Posted by jpn View Post
    This is how we do it in LibQxt project:
    Qt Code:
    1. #check Qt version
    2. QT_VERSION = $$[QT_VERSION]
    3. QT_VERSION = $$split(QT_VERSION, ".")
    4. QT_VER_MAJ = $$member(QT_VERSION, 0)
    5. QT_VER_MIN = $$member(QT_VERSION, 1)
    6.  
    7. lessThan(QT_VER_MAJ, 4) | lessThan(QT_VER_MIN, 2) {
    8. error(LibQxt requires Qt 4.2 or newer but Qt $$[QT_VERSION] was detected.)
    9. }
    To copy to clipboard, switch view to plain text mode 
    It would be nice if there was a built-in version check function in qmake...
    Humm the code above will display the message for a 5.0 version also no ?

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt version checking at the project-file

    Yes, but that code is from 2008 when there was no Qt5 only Qt3 and Qt4. LibQxt no longer checks to exclude Qt3.

    For Qt4+ you can just:
    Qt Code:
    1. greaterThan(QT_MAJOR_VERSION, 4) {
    2. }
    3. equals(QT_MAJOR_VERSION, 5) {
    4. }
    5.  
    6. # or more complex stuff like
    7. equals(QT_MAJOR_VERSION, 4):lessThan(QT_MINOR_VERSION, 8) {
    8. }
    To copy to clipboard, switch view to plain text mode 
    QT_MAJOR_VERSION, QT_MINOR_VERSION, and QT_PATCH_VERSION are defined for you.

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. Set up the Qt4.3.2 with Visual Studio 2005
    By lamoda in forum Installation and Deployment
    Replies: 6
    Last Post: 30th January 2008, 06:51
  3. Distributing QT application for Mac OS
    By mb0 in forum Qt Programming
    Replies: 1
    Last Post: 31st May 2007, 18:59
  4. How to specify compiler version in project file
    By mdecandia in forum Qt Programming
    Replies: 2
    Last Post: 18th May 2007, 11:03
  5. Replies: 15
    Last Post: 21st April 2007, 17:46

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.