Nominate our 2022 Qt Champions!

[Solved] Strange error

  • Hellow when i try compile this code:
    @QString str = QDir::currentPath + "\settings.ini";@
    I get strange error: Error 2 error C2296: +: invalid, the left operand is of type "QString (__cdecl *) (void)" c: \ Documents and Settings \ rustam \ My Documents \ Visual Studio 2008 \ Projects \ RizekColorManager \ RizekColorManager \ Settings \ Settings.cpp 30
    But there are "QString QDir::currentPath ()" in assistant
    Why is this happening?
    Advance many thanks for uour help!

  • QDir::currentPath is the name of a static method of QDir class. so:
    QString str = QDir::currentPath() + "\settings.ini";

  • and don't forget to use double backslash in your static filename.

  • Oh, sorry completion went wrong, and I did not notice
    Many thanks for your help!

  • [quote author="Andreas Hammerschmidt" date="1309281322"]and don't forget to use double backslash in your static filename.[/quote]

    Better yet, use a single forward slash. If you want to display the path as a string, you can use QDir::toNativeSeparators().

  • thats same problem with me, solved mine either.. thanks

Log in to reply