From 38fc6ad3e789c69dd09b0c494ead107d6da10807 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 9 May 2016 20:24:04 -0700 Subject: Don't use qDebug for formatted output - but QDebug is ok That's the difference between readable output and unreadable mess. Good: QPlatformSurfaceEvent(surfaceEventType=SurfaceCreated) QEvent(WinIdChange, 0x7ffdadee2bd0) QEvent(WindowIconChange, 0x7ffdadee2d30) Bad: [351295.324] qev(88029 88029)(Widget::event|QApplicationPrivate::notify_helper|QApplication::notify|QCoreApplication::notifyInternal2|QCoreApplication::sendEvent|?libQt5Widgets.t.so.5?|QApplicationPrivate::notify_helper|QApplication::notify|QCoreApplication::notifyInternal2|QCoreApplication::sendEvent): QPlatformSurfaceEvent(surfaceEventType=SurfaceCreated) [351295.333] qev(88029 88029)(Widget::event|QApplicationPrivate::notify_helper|QApplication::notify|QCoreApplication::notifyInternal2|QCoreApplication::sendEvent|QWidgetPrivate::setWinId|QWidgetPrivate::create_sys|QWidget::create|QWidget::setVisible|QWidget::show): QEvent(WinIdChange, 0x7ffca6714280) [351295.333] qev(88029 88029)(Widget::event|QApplicationPrivate::notify_helper|QApplication::notify|QCoreApplication::notifyInternal2|QCoreApplication::sendEvent|?libQt5Widgets.t.so.5?|QApplicationPrivate::notify_helper|QApplication::notify|QCoreApplication::notifyInternal2|QCoreApplication::sendEvent): QEvent(WindowIconChange, 0x7ffca67143e0) Change-Id: Id69569111e7d4e619e22ffff144d16fb04876219 Reviewed-by: Friedemann Kleint --- src/qev/qev.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/qev/qev.cpp') diff --git a/src/qev/qev.cpp b/src/qev/qev.cpp index aff170d97..bd30e64b1 100644 --- a/src/qev/qev.cpp +++ b/src/qev/qev.cpp @@ -38,6 +38,8 @@ QT_USE_NAMESPACE +QIODevice *qout; + class Widget : public QWidget { public: @@ -46,7 +48,7 @@ public: bool event(QEvent *e) { if (e->type() == QEvent::ContextMenu) return false; - qDebug() << e; + QDebug(qout) << e << endl; return QWidget::event(e); } }; @@ -55,6 +57,11 @@ public: int main(int argc, char **argv) { QApplication app(argc, argv); + + QFile fout; + fout.open(stdout, QIODevice::WriteOnly); + qout = &fout; + Widget w; w.show(); return app.exec(); -- cgit v1.2.1