[SOLVED]qmake does not write QT += widgets to *.pro file



  • Hi, every one.
    I am new to Qt, and I find it fansinating to write Qt applications. Here is the question.
    @qmake -project@ and generates sample.pro, but there's no
    @QT += widgets@ and I have to add it to the .pro file. How can I make it generate this line automatically?

    thank you all.



  • there is what I found in qmake help:
    @
    Mode:
    -project
    Put qmake into project file generation mode
    In this mode qmake interprets files as files to
    be built,
    defaults to *; *; *; *.ts; *.xlf; *.qrc
    Note: The created .pro file probably will
    need to be edited. For example add the QT variable to
    specify what modules are required.
    @

    so I think there is no built-in way to generate QT variable automatically


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    qmake can't to that for you because it doesn't know that you are going to use widgets in your project (Qt Creator can because you tell it so)



  • echo QT += widgets>>sample.pro



  • thanks, maybe I should edit it maunally.
    [quote author="MrMNight" date="1395825165"]there is what I found in qmake help:
    @
    Mode:
    -project
    Put qmake into project file generation mode
    In this mode qmake interprets files as files to
    be built,
    defaults to *; *; *; *.ts; *.xlf; *.qrc
    Note: The created .pro file probably will
    need to be edited. For example add the QT variable to
    specify what modules are required.
    @

    so I think there is no built-in way to generate QT variable automatically[/quote]



  • Then is there any chance I can tell qmake that I am gonna use widgets? Perhaps it is an option or something. Accurally I am trying the samples in C++ GUI programming with Qt4, 2nd Edition. The earlier samples are written in plain text editors.
    [quote author="SGaist" date="1395871610"]Hi and welcome to devnet,

    qmake can't to that for you because it doesn't know that you are going to use widgets in your project (Qt Creator can because you tell it so)[/quote]



  • I wonder maybe I can modify the source file but leave the modified .pro file alone, and qmake sample.pro directely. I will give a shot.
    [quote author="MarianMMX" date="1395871982"]echo QT += widgets>>sample.pro[/quote]


  • Lifetime Qt Champion

    Currently no, there's not.

    In Qt 4 the widgets where in the gui module which is one of the default module. That's why the generated pro file was enough.

    However there's nothing wrong modifying the pro file by hand. qmake -project is generally called once to start using Qt with an existing code base then the file is modified to suite the needs of the project e.g. OpenGL, Sql, other libraries/frameworks you want to use.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.