Help with Qt4 and Xcode projects

Discussion in 'Mac Programming' started by jbenitez, Jan 9, 2008.

  1. jbenitez macrumors newbie

    Joined:
    Jan 9, 2008
    #1
    Hi, I'm new to Qt4 and have experience with Xcode. :) I installed Qt4 using
    qt-mac-opensource-4.3.2.dmg. I was able to build and run all the tutorial
    examples.

    I'm trying to build a NEW project using .cpp and .h files from 2 examples.
    I created a NEW directory and put these files in it. Then I ran the following.

    qmake -project / this creates a .pro file in my NEW dir
    qmake -spec mac-xcode / this creates a .xcodeproj file in my NEW dir

    I've noticed that the .pro file created in my NEW dir is different that
    the .pro files in the tutorial examples.

    I get "error:QtSql: no such file or directory" for the #include <QtSql> statement.

    I get "error:QtSqlQueryModel: no such file or directory" for the #include
    <QtSqlQueryModel> statement.

    I get many more errors about 48 of them.

    I don't understand why Xcode can't find these header files in my NEW project, but it does
    find all header files in the tutorial examples.

    What am I doing wrong? Your help is greatly appreciated!

    Very confused,
    :confused:

    Jbenitez
     
  2. simon-says macrumors regular

    Joined:
    May 24, 2005
    Location:
    Shreveport, LA
    #2
    You need to link against the QtSql module, have you done this? Inside your .pro file at the top you need to add the line "QT += sql". After that run the `qmake -spec macx-xcode` line from terminal. This should solve your problems. Let me know if that does not solve your problem.

    - Brent Nycum
     
  3. jbenitez thread starter macrumors newbie

    Joined:
    Jan 9, 2008
    #3
    Awsome Brent! Adding "QT += sql". to my .pro file fixed the problem!:) I'm very glad to see it does work.

    So, do I have to "manually" add this type of statement every time I need to use a different class / module?

    How does on know to use "+= sql" and not "+= QtSql" ?

    Is there a more "automatic" way of doing this? Or, is this the way things work with Qt and Xcode projects?

    Once again, Thank You very much for your time! :)

    Jbenitez
     
  4. simon-says macrumors regular

    Joined:
    May 24, 2005
    Location:
    Shreveport, LA
    #4
    Sorry I'm late on replying I have been out of town. Yes, you will have to manually go into the .pro file and add modules this way. By using 'sql' and not 'QtSql' it is telling which module you need to load. You would add the OpenGL module with "+= opengl". There might be a flag or something you can pass into 'qmake -project' but I am not totally positive on that as I normally just manually go in and do that. You would have to do this the same way if you were making a Visual Studio project or just a makefile. The only thing you would change is the type of project you generate.

    - Brent Nycum
     
  5. jbenitez thread starter macrumors newbie

    Joined:
    Jan 9, 2008
    #5
    QT & Xcode

    Thanks for your reply. I will play around with this some more. I'm looking into using some widgets called Qwt. I tried before and had similar problems finding header files. Have you used Qwt?

    I'm going to try and link to the Qwt modules the same way. I'm thinking it should work. Wish me luck! :)

    Jbenitez
     

Share This Page