Results 1 to 2 of 2

Thread: Possible bug in qt creator

  1. #1
    Join Date
    Apr 2012
    Posts
    10
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Possible bug in qt creator

    In short sources don't appear in qt creator but project can build.
    This is my qmake
    Qt Code:
    1. QT += core gui
    2.  
    3. TARGET = Disigner
    4. TEMPLATE = app
    5.  
    6. !include( ../Common.pri)::warning(Fail to include Common.pri)
    7.  
    8. sourcesPath = #Sources
    9. headersPath = #Sources
    10. tempSources += main.cpp
    11. tempSources += Designer.cpp
    12.  
    13. tempHeaders += Designer.h
    14.  
    15. compliteSources += $$ApendPath(sourcesPath,tempSources)
    16. compliteHeaders += $$ApendPath(headersPath,tempHeaders)
    17.  
    18. finalSources += $$compliteSources
    19. finalHeaders += $$compliteHeaders
    20.  
    21. message($$finalSources)
    22. message($$finalHeaders)
    23. SOURCES += $$finalSources
    24. HEADERS += $$finalHeaders
    To copy to clipboard, switch view to plain text mode 

    This is my Common.pri
    Qt Code:
    1. defineReplace(ApendPath){
    2. Path = $$eval($$1)
    3. FileNames = $$eval($$2)
    4. FullNames =
    5.  
    6. if(Path){
    7. for(FileName,FileNames){
    8. FullName = $${Path}/$${FileName}
    9. FullNames += $$FullName
    10. }
    11.  
    12. } else {
    13.  
    14. for(FileName,FileNames){
    15. FullName = $${FileName}
    16. FullNames += $$FullName
    17. }
    18.  
    19. }
    20.  
    21. return ($$FullNames)
    22. }
    To copy to clipboard, switch view to plain text mode 

    If i comment "SOURCES += $$finalSources" and add "SOURCES += main.cpp Designer.cpp" sources appear again in qt creator again.

  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: Possible bug in qt creator

    Qt Creator extracts the source file names from the SOURCES and HEADERS in pro and pri files by parsing the files. It understands explicitly named files, globs, and some variable expansions. If there are no files listed there, as is the case here, then there are no files in the project. With your attempt at a completely dynamic setup the only way that Qt Creator could possibly know which files qmake would ultimately include in SOURCES/HEADERS with your dynamic setup would be to 'run' the PRO file internally and intercept the end result.


    The globbing and expansion functionality may help you here. This, for example, works:
    Qt Code:
    1. TEMPLATE = app
    2. someothersources = ../other.cpp
    3. SOURCES += *.cpp $${someothersources}
    4. HEADERS += *.h
    To copy to clipboard, switch view to plain text mode 
    picking up all the CPP and H files in the directory but it will not notice new files created outside until you force it to reparse the pro file.

    If I understand what you are trying to achieve:
    qmake Code:
    1. ##top.pro
    2. TEMPLATE = app
    3.  
    4. include(headers/headers.pri)
    5. include(sources/sources.pri)
    6.  
    7. ##headers/headers.pri
    8. HEADERS += $${PWD}/*.h
    9.  
    10. ##sources/sources.pri
    11. SOURCES += $${PWD}/*.cpp
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 18th October 2012 at 14:19. Reason: reformatted to look better

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

    themean (18th October 2012)

Similar Threads

  1. Replies: 2
    Last Post: 22nd November 2011, 01:09
  2. QT creator +SDL
    By ShapeShiftme in forum Qt Tools
    Replies: 2
    Last Post: 19th December 2010, 12:44
  3. QT creator
    By tertius in forum Newbie
    Replies: 7
    Last Post: 21st June 2010, 11:41
  4. QT Creator
    By vinod sharma in forum Qt Tools
    Replies: 2
    Last Post: 22nd January 2010, 09:34
  5. Qt Creator on Mac OS X
    By stephenju in forum Qt Tools
    Replies: 2
    Last Post: 12th March 2009, 22:51

Tags for this Thread

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.