Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [Solved] QMessageLogContext does not name a type with Qt SDK 5.0.2 - Ubuntu
Forum Updated to NodeBB v4.3 + New Features

[Solved] QMessageLogContext does not name a type with Qt SDK 5.0.2 - Ubuntu

Scheduled Pinned Locked Moved Installation and Deployment
11 Posts 3 Posters 9.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    code_fodder
    wrote on last edited by
    #1

    Hi Guys,

    Sorry for the long post, I think the question is relatively simple, but I feel the need to explain the situation I got myself into, however you can probably jump straight to the "Questions" section at the end :) ...

    I have been using Qt SDK 5.0.2 on Windows and Linux with much success :)

    However, I am now expanding my operation and trying to make a sound build environment and a repeatable process to make it. I have almost got there but I have a couple of little niggles left.

    Problem Description
    Using virtual box to keep testing my installations I am creating systems with Ubuntu 12.04 + all updates. This was my process:

    1. install QtCreator from the Ubuntu software centre (this was a mistake I think)
    2. Uninstall Qt Creator from the Ubuntu software centre.
    3. Download Qt SDK 5.0.2 from "qt-project.org/downloads", then cd to the download directory and do:
      @sudo chmod +x qt-linux-opensource-5.0.2-x86-offline.run
      sudo ./qt-linux-opensource-5.0.2-x86-offline.run@

    Other then installing Qt Creator and un-installing it, everything is the same as my working Linux version (on real PC, i.e. non-Virtual box)

    But I get the following issue:
    @main.cpp:60:45: error: 'QMessageLogContext' does not name a type
    main.cpp:60:65: error: ISO C++ forbids declaration of 'context' with no type [-fpermissive]
    main.cpp: In function 'void qDebugMsgHandler(QtMsgType, const int&, const QString&)':@

    Here is my code (which works very well on my Qt 5.0.2 on windows and my other linux installation:
    @// Message handler for qDebug(), qWarning(), qCritical(), qFatal().
    // Note: For qDebug() there are no automatic end-of-lines for maximum
    // flexibility this means that you need to put a "\n" or << endl; at
    // the end of your message.

    void qDebugMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
    {
    QByteArray localMsg = msg.toLocal8Bit();
    switch (type) {
    case QtDebugMsg:
    myprintf(OUT_ALL, "%s", localMsg.constData());
    break;
    case QtWarningMsg:
    myprintf(OUT_ALL, "\nWarning: %s \t%s (line %u) in %s\n\n", localMsg.constData(), context.file, context.line, context.function);
    break;
    case QtCriticalMsg:
    myprintf(OUT_ALL, "\nCritical: %s \t%s (line %u) in %s\n\n", localMsg.constData(), context.file, context.line, context.function);
    break;
    case QtFatalMsg:
    myprintf(OUT_ALL, "\nFatal: %s \t%s (line %u) in %s\n\n", localMsg.constData(), context.file, context.line, context.function);
    abort();
    }
    }@

    Questions

    1. QMessageLogContext is a Qt 5 addition. It looks like I don't have that library. When I add the line '#include <QMessageLogContext>', the tool tip even says "can't find file". So how do I install this library?

    2. Also my include paths during the build are suspect, for example:
      @g++ -c -pipe -Wall -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_XML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtXml -I/usr/include/qt4 -Icommsnet -Icommsnet/device -Icommsnet/vocoder -Iconfig -Iif -Irpe -Irtp -ItacChat -Iutils -I../_out -o ../_out/main.o main.cpp@
      You can see there are not Qt5 paths whereas on my other linux build there are many more paths like "usr/share/Qt5.0.2/5.0.2/gcc/include/QtCore, etc.... does this mean that I don't have Qt 5 properly installed?

    3. What can I do about this to update it?

    I have the feeling when I installed Qt Creator on its own I screwed up :( , but I am not sure if that is the issue or not

    EDIT: forgot to add: When I remove this code (i.e. comment it out) my project builds and runs great :). I figure that most of the stuff I use is pre Qt5 stuff .. so at least I have some sort of working version of Qt :o

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Max Krause
      wrote on last edited by
      #2

      [deleted]

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        It seems you are using a Qt 4 qmake which probably is the one installed with your system's Qt development package.

        Did you take a look into your QtCreator Qt versions ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • C Offline
          C Offline
          code_fodder
          wrote on last edited by
          #4

          This is from the "about" in my Qt Creator GUI:

          @Qt Creator 2.7.0
          Based on Qt 5.0.2 (32 bit)

          Built on Apr 9 2013 at 09:31:06

          From revision b6257ef735

          Copyright 2008-2013 Digia Plc. All rights reserved.

          The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.@

          Is that what you mean?
          Is there another place I can see the versions?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            No it's not, the version of Qt used to build QtCreator and the one you use to build your application are not related.

            Go to Options/Preferences -> Build & Run -> Qt Versions

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • C Offline
              C Offline
              code_fodder
              wrote on last edited by
              #6

              Ahh.... I see... this makes sense now!, here is what it says:

              Auto Detect:
              Qt 5.0.2 GCC 32bit /opt/Qt5.0.2/5.0.2/gcc/bin/qmake

              Manual:
              Qt 4.8.1 in PATH (System) /usr/bin/qmake-qt4

              I think you are right, so what do I need to change to make that Qt5?, just point it to the Qt5 path? (where would that be?)

              1 Reply Last reply
              0
              • C Offline
                C Offline
                code_fodder
                wrote on last edited by
                #7

                But... I just looked at my working Linux and that is exactly the same :(, except it has a different "manual" version 4.6.2...

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Go in the Kits tab and either add a new kit using your Qt 5 or change the current kit to use your Qt 5

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    code_fodder
                    wrote on last edited by
                    #9

                    Right... so, I have no idea exactly what happened, but this has fixed my issue! :)

                    What I did was:
                    Attempted to "Add..." and kit in the build and run menu. Saw loads of options that I did not understand. Then cancelled it. Went back in and saw a new "Desktop" entry under "Manual:". I clicked on new entry again, click auto-detect a few times... Then finally I deleted my new entry.

                    After that I could not build my project (option was greyed out).

                    Then I closed and opened Qt Creator and tried again, it came up with the "you need to configure your project" page (like when you get the project with no .pro.user file). I had two options, I check the one that had 5.0.2 in it and un-checked the other.

                    Then... it all just works! - I have the same kits and versions in my build & run options...
                    I guess this allowed Qt to update itself or something?

                    Anyway, here is my build output:
                    @g++ -c -pipe -Wall -g -Wall -W -D_REENTRANT -fPIE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_XML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I/opt/Qt5.0.2/5.0.2/gcc/mkspecs/linux-g++ -I. -Icommsnet -Icommsnet/device -Icommsnet/vocoder -Iconfig -Iif -Irpe -Irtp -ItacChat -Iutils -I/opt/Qt5.0.2/5.0.2/gcc/include -I/opt/Qt5.0.2/5.0.2/gcc/include/QtXml -I/opt/Qt5.0.2/5.0.2/gcc/include/QtNetwork -I/opt/Qt5.0.2/5.0.2/gcc/include/QtCore -I../_out -o ../_out/main.o main.cpp
                    @

                    Thanks very much for your help SGaist :)

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Great !

                      You're welcome !

                      Don't forget to update the thread's title to solved so other forum users may know that a solution has been found :)

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        code_fodder
                        wrote on last edited by
                        #11

                        Ahhh.... I never knew how that happened!, I thought it was an admin guy doing that :o

                        I will update it now.
                        Thanks

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved