Important: Please read the Qt Code of Conduct -

"Multiple parse contexts" in Qt creator

  • Not sure what is meant here:

    This comes from Qt creator latest version 4.3.1 on windows 10,in case it matters.

    I am at a loss what I can do to get rid of it. Obviously, I can use "Do Not Show Again" which is on the right of the message, but I prefer to know, what I am ignoring.

    What are possible causes?

  • Lifetime Qt Champion

    Most likely you have multiple (Sub-)projects containg this file. Depending on the parse context, different defines may be active that influence the parsing of this file

  • Lifetime Qt Champion

    Do you use sessions?

    Anyway, its not clear from source what is being checked

    CppTools::BaseEditorDocumentProcessor *CppEditorDocument::processor()
                const bool isAmbiguous = info.hints & ProjectPartInfo::IsAmbiguousMatch;
                const bool isProjectFile = info.hints & ProjectPartInfo::IsFromProjectMatch;
                showHideInfoBarAboutMultipleParseContexts(isAmbiguous && isProjectFile); // this shows msg

    The IsFromProjectMatch flag is set here

            // Hints
            if (m_info.projectParts.size() > 1)
                m_info.hints |= ProjectPartInfo::IsAmbiguousMatch;
            if (prioritized.first().priority > 1000)
                m_info.hints |= ProjectPartInfo::IsPreferredMatch;
            if (areProjectPartsFromDependencies)
                m_info.hints |= ProjectPartInfo::IsFromDependenciesMatch;
                m_info.hints |= ProjectPartInfo::IsFromProjectMatch;

    so it seems to be related to sort / classify files depending on origin but didnt really see the meaning of
    multiple contexts.

    update: yep, as @aha_1980 says, sub projects might trigger this , it seems from the code.

    [Added code tags ~kshegunov]

  • Thanks guys.

    Yes, I am using subprojects.
    Yes, I am using sessions.

    Within the session I have/had a couple of projects which I have also put into a subdirs project,which is also open.

    Apparently the message is an one time display, because it does not vanish after:

    • closing the duplicates
    • changing to another file

    I was using a search over all projects with some text. That might have triggered the message.
    I guess for the first time, it might make sense for a file. However, when switching to another file, the meaning is lost, because the message refers to "this file".

    The description of the bug report does not really fit my case.

    How can I choose a prefered one then?

  • Lifetime Qt Champion

    you can select the active parse context with drop down box (3) from

  • @aha_1980

    Thanks for link. That is exactly what I was looking for.

    As a side note, the dropdown box is not always visible. I had realized that there was something, but could not really make it out. In addition the content was not obviously related to my issue. Probably, I have seen the box the first time in that context.
    IMHO the warning text is ambigious, which causes confusion. However, rather than just complaining about it, which is always easy, I cannot offer an alternative text.