Book example build failed for Qt 4.7.3



  • I have download the code for book "Advanced Qt Programming" written by Mark Summerfield.

    I use QtCreator 2.2.1 to open the .pro and try to build it using VC 2008 (Qt SDK 1.1.2) and got build error:
    @'cos': is not a member of 'std'@
    in file "datetimedelegate.cpp":
    @#ifdef MSVC_COMPILER
    const qreal x = length * cos(angle);
    const qreal y = length * sin(angle);
    #else
    const qreal x = length * std::cos(angle);
    const qreal y = length * std::sin(angle);
    #endif@
    Why? I have checked the project property and it said it is:
    Qt 4.7.3 for Desktop - MSVC2008(Qt SDK)



  • You might want to include "QtCore/qmath.h":http://developer.qt.nokia.com/doc/qt-4.7/qtcore-qmath-h.html and use qSin() and qCos() instead:

    @
    #include <QtCore/qmath.h>

    const qreal x = length * qSin(angle);
    const qreal y = length * qCos(angle);
    @



  • Does anyone have build the book source code successfully using Qt SDK 4.7.3 (Qt Creator 2.2.1)?


  • Moderators

    I did succesfully use the pagedesigner2 project. Which project are you interested in? I can give that a try.

    I'm using Qt Creator 2.2.1 also but based on Qt 4.7.4 (32 bit)
    i can build for 4.7.3 and also 4.8.(project settings)

    I think your problem is probably with msvc2008 and path settings. But I'm using mingw so i can't be of much assistance in your case.



  • several projects like:
    Folderview
    petridish1
    petridish2

    Yes, It comes from:
    #ifdef MSVC_COMPILER
    it looks like MSVC_COMPILER is not defined.

    and using MinGW build OK.

    I fixed it by add:

    #include <cmath>

    to all files contain "MSVC_COMPILER"

    BUT, still, I can not build the project "textedit" by using VC 2008


Log in to reply
 

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