Results 1 to 18 of 18

Thread: qmake behavior

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake behavior

    Thanks ChrisW67! This seems to work! I added "int trythis;" into a header, recompiled (not so long recompiling, not everything got rebuilt evidently), run debug and inspected the class. It contained "trythis" as it should do. My makefile now contains references to header files. It did not before.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qmake behavior

    Out of curiosity (I didn't get a response last time I indirectly asked about it) -- how exactly do you include statements look like? Do they use relative paths? I mean do they look like:

    Qt Code:
    1. #include "../hpp/myframe.hpp"
    To copy to clipboard, switch view to plain text mode 

    or rather

    Qt Code:
    1. #include "myframe.hpp" // or <myframe.hpp>
    To copy to clipboard, switch view to plain text mode 

    ?

    If DEPENDPATH helps then it is likely you are using the latter.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake behavior

    #include <myframe.hpp> with all my headers. That's why I have set INCLUDEPATH.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qmake behavior

    For that you need DEPENDPATH as well

    See the docs (underlined by me):

    Quote Originally Posted by DEPENDPATH

    This variable contains the list of all directories to look in to resolve dependencies. This will be used when crawling through included files.
    INCLUDEPATH is only used for compilation (e.g. it makes no sense to make your app dependent of /usr/include/*, right?).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Nov 2013
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake behavior

    I don't wish to start new thread for this small question:

    I have the source code tree of existing project, where every .cpp file for class, inherited from QObject, ends with inclusion of "class_name.moc" file.
    I try to make the Qt project file to use with QtCreator for this sources.
    The problem is in that qmake generates makefile, where *.cpp file depends on corresponding *.moc file, but the *,moc file rules only generated for *.cpp, wich declares private classes, inherited from QObject.

    Is it possible to generate makefile with rules to make *.moc files for every *.cpp with *.moc inclusion?

    Example:
    class1.h
    Qt Code:
    1. #include <qt4/QtCore/QObject>
    2. class Class1 : public QObject
    3. {
    4. Q_OBJECT
    5. public:
    6. Class1();
    7. };
    To copy to clipboard, switch view to plain text mode 

    class1.cpp
    Qt Code:
    1. #include "class1.h"
    2.  
    3. Class1::Class1()
    4. {
    5. }
    6. #include "class1.moc"
    To copy to clipboard, switch view to plain text mode 

    class1.pro
    Qt Code:
    1. TEMPLATE = lib
    2. INCLUDEPATH += .
    3.  
    4. HEADERS += class1.h
    5. SOURCES += class1.cpp
    To copy to clipboard, switch view to plain text mode 

    qmake
    make
    ...
    No rule to make target `class1.moc', needed by `class1.o'.

    But if cpp will be modified:
    class1.cpp
    Qt Code:
    1. #include "class1.h"
    2.  
    3. class Private : public QObject
    4. {
    5. Q_OBJECT
    6. };
    7.  
    8. Class1::Class1()
    9. {
    10. }
    11.  
    12. #include "class1.moc"
    To copy to clipboard, switch view to plain text mode 
    then lib is generated correctly.

  6. #6
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qmake behavior

    I have seen such #includes, too, but, luckily, I didn't need to compile it I am still a beginner but, IMO, the *.moc files are some relic of Qt3. In a Qt4 project, you do not create *.moc files. AFAIK, the *.moc files aren't a part of a Qt4 project directly: you find files like moc_class1.o in the compiled project but no class1.moc file.

    I recommend checking whether the *.moc files contain something what should be in your *.cpp and *.hpp files. If they do then update the source files accordingly. If they don't (they contain only dependencies, includes and similar things) then comment all "#include something.moc" out, create a Qt4 project, add all sources and headers and compile. You should pass (if it is a Qt3 project, you might need the Qt3 support). The MOC info should be processed by qmake without your intervention.

  7. #7
    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 behavior

    Quote Originally Posted by Radek View Post
    IMO, the *.moc files are some relic of Qt3.
    No, they are just a different way of dealing with the code generated by MOC.

    Without the include the behavior is to generate cpp files which are then compiled separately and linked like any other object file.

    The alternative with the include is used in three scenarios:
    1) when the Q_OBJECT using class declaration is inside the cpp file, not in a header
    2) when the code generated by moc needs to see some declarations that are private to the cpp file
    3) to speed up builds (no extra invocation of compiler for the moc generated file)

    Not sure why it doesn't work for starling13 though.

    Cheers,
    _

Similar Threads

  1. QMAKE FLAGS in qmake.conf for solaris-cc-64 uses old flags
    By qmake_query in forum Installation and Deployment
    Replies: 0
    Last Post: 16th October 2012, 09:11
  2. QGraphicsView Behavior
    By chaoticbob in forum Qt Programming
    Replies: 1
    Last Post: 15th October 2009, 10:23
  3. qmake DESTDIR permissions behavior (Unix)
    By wdezell in forum Qt Tools
    Replies: 3
    Last Post: 9th March 2009, 14:59
  4. Odd behavior...
    By TemporalBeing in forum Qt Programming
    Replies: 0
    Last Post: 28th February 2009, 00:45
  5. QTreeView behavior
    By killerwookie99 in forum Qt Programming
    Replies: 1
    Last Post: 11th February 2009, 20:29

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
  •  
Qt is a trademark of The Qt Company.