Results 1 to 5 of 5

Thread: qmake conditional expressin, strange behaviour

  1. #1
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default qmake conditional expressin, strange behaviour

    Hello,

    I am trying to write a conditional expression on my .pro file:

    Qt Code:
    1. DEFINES += MIKRODIAGRAM_EDITOR
    2. contains(DEFINES, MIKRODIAGRAM_EDITOR) {
    3. SUBDIRS += diagramEditor
    4. warning(DiagramEditor Plugin activated)
    5. }
    6. else{
    7. SUBDIRS += scadaEditor
    8. warning(ScadaEditor Plugin activated)
    9. }
    To copy to clipboard, switch view to plain text mode 

    On Qt Creator(3.1) output console , I see only "DiagramEditor Plugin activated" text as it should. But Qt Creator adds both "diagramEditor" and "scadaEditor" folders to the project tree. Is this a bug or something else?

    Thanks in advance...

  2. #2
    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: qmake conditional expressin, strange behaviour

    Qt Creator shows both source directories in the project because both source directories are part of the project. That you choose to include one or the other at build time is not relevant to the process of editing the source of the project.

  3. The following user says thank you to ChrisW67 for this useful post:

    yagabey (18th May 2014)

  4. #3
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: qmake conditional expressin, strange behaviour

    Hmm ok , thanks. Is there a way to hide the source tree conditionally?

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qmake conditional expressin, strange behaviour

    Put the different parts into .pri files (project includes) and have two .pro files that include the things for each variant.

    Then you open whatever variant you are working on.

    Cheers,
    _

  6. The following user says thank you to anda_skoa for this useful post:

    yagabey (18th May 2014)

  7. #5
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: qmake conditional expressin, strange behaviour

    The project tree is a bit complicated. I dont want to make any changes on .pri files. I am trying to solve the problem with 2 different .pro files. In one of them i have:

    Qt Code:
    1. DEFINES += MIKRODIAGRAM_EDITOR
    To copy to clipboard, switch view to plain text mode 

    and in the other one i have:

    Qt Code:
    1. DEFINES += MIKROSCADA_EDITOR
    To copy to clipboard, switch view to plain text mode 


    The definition is not valid on the sub .pro and .pri files. The code below is in one of the sub .pro files:

    Qt Code:
    1. contains(DEFINES, MIKRODIAGRAM_EDITOR) {
    2. SUBDIRS += diagramEditor
    3. warning(DiagramEditor Plugin activated)
    4. }
    5. else{
    6. SUBDIRS += scadaEditor
    7. warning(ScadaEditor Plugin activated)
    8. }
    To copy to clipboard, switch view to plain text mode 

    always returns "ScadaEditor Plugin activated". Isn't the scope of DEFINES valid through all the project?

Similar Threads

  1. Qmake question, support for conditional compilation?
    By HowardHarkness in forum Newbie
    Replies: 2
    Last Post: 25th May 2012, 21:52
  2. Need help: Strange behaviour
    By navi1084 in forum Qt Programming
    Replies: 3
    Last Post: 14th November 2008, 04:03
  3. Strange behaviour of QPainter...
    By oscar in forum Qt Programming
    Replies: 2
    Last Post: 8th November 2008, 12:07
  4. Very strange (perhaps) QHttp behaviour.
    By Kumosan in forum Qt Programming
    Replies: 5
    Last Post: 11th June 2008, 07:03
  5. very strange behaviour
    By regix in forum Qt Programming
    Replies: 23
    Last Post: 20th July 2006, 17:38

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.