[Interest] can't dump QStringList with qDebug()

Hamish Moffatt hamish at risingsoftware.com
Wed Mar 8 02:21:11 CET 2023

On 8/3/23 04:15, Thiago Macieira wrote:
> On Monday, 6 March 2023 22:15:01 PST Hamish Moffatt via Interest wrote:
>> ../../../../Qt6.4.2/6.4.2/gcc_64/include/QtCore/qdebug.h:217:53: note:
>> candidate template ignored: requirement
>> 'std::conjunction_v<std::disjunction<std::is_base_of<QList<QString>,
>> QString>, QTypeTraits::has_ostream_operator<QDebug, QString, void>>>' was
>> not satisfied [with T = QString]
> This is the expected template and the compiler told us why it couldn't expand:
> it thinks that the QDebugIfHasDebugStreamContainer condition wasn't satisfied.
> That condition is
> std::is_base_of<Container, T> OR QTypeTraits::has_ostream_operator<Stream, T>
> Obviously, QStringList is not a base class of QString; we're expecting the
> second check to be true, that there's an output streaming operator for QDebug-
> QString
> That of course is there; it's in QDebug itself.
> So my conclusion is that your compiler has a bug and improperly parsed the C++
> code. Does this problem happen with GCC 11 or 12?
I said gcc 10 earlier, but I meant to say clang 11. But I also see it in 
clang 14, and in VS 2019 (17.5.1 - latest).

It seems to be related to #including the moc output in the cpp file.

Here's a minimal example:

Header file:

#pragma once

#include <QObject>
#include <QString>

namespace TServer

	class Test : public QObject

		void test();

		void databaseOpened(QString schoolCode);
		void databaseEvent(QString schoolCode, QString notification);
		void databaseRemoved(QString schoolCode, QString dbFilename);


Source file:

#include "server_database2.h"
#include <moc_server_database2.cpp>

#include <QDebug>

void TServer::Test::test()
	qDebug() << QStringList{};


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20230308/e309955f/attachment.htm>

More information about the Interest mailing list