From 0fa201d84468d82bec4268971eba865c50606e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 25 Sep 2009 13:07:42 +0200 Subject: Use qDebug() instead of printf() when dumping the simplex matrix. printf() does not work very well on windows, since it will not send the output to OutputDebugString(). This allows us to catch the output even if the program is configured without "CONFIG += console". --- .../graphicsview/anchorlayout/anchorlayout.pro | 1 + src/gui/graphicsview/qsimplex_p.cpp | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/examples/graphicsview/anchorlayout/anchorlayout.pro b/examples/graphicsview/anchorlayout/anchorlayout.pro index c969c8b..c2a1bea 100644 --- a/examples/graphicsview/anchorlayout/anchorlayout.pro +++ b/examples/graphicsview/anchorlayout/anchorlayout.pro @@ -12,3 +12,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/anchorlayout INSTALLS += target sources TARGET = anchorlayout_example +CONFIG+=console \ No newline at end of file diff --git a/src/gui/graphicsview/qsimplex_p.cpp b/src/gui/graphicsview/qsimplex_p.cpp index 94eb5c0..1ba24a3 100644 --- a/src/gui/graphicsview/qsimplex_p.cpp +++ b/src/gui/graphicsview/qsimplex_p.cpp @@ -333,23 +333,21 @@ void QSimplex::clearColumns(int first, int last) void QSimplex::dumpMatrix() { - printf("---- Simplex Matrix ----\n"); + qDebug("---- Simplex Matrix ----\n"); - printf(" "); + QString str(QLatin1String(" ")); for (int j = 0; j < columns; ++j) - printf(" <% 2d >", j); - printf("\n"); - + str += QString::fromAscii(" <%1 >").arg(j, 2); + qDebug("%s", qPrintable(str)); for (int i = 0; i < rows; ++i) { - printf("Row %2d:", i); + str = QString::fromAscii("Row %1:").arg(i, 2); qreal *row = matrix + i * columns; - for (int j = 0; j < columns; ++j) { - printf(" % 2.2f", row[j]); - } - printf("\n"); + for (int j = 0; j < columns; ++j) + str += QString::fromAscii("%1").arg(row[j], 7, 'f', 2); + qDebug("%s", qPrintable(str)); } - printf("------------------------\n\n"); + qDebug("------------------------\n"); } void QSimplex::combineRows(int toIndex, int fromIndex, qreal factor) @@ -474,7 +472,7 @@ bool QSimplex::iterate() setValueAt(pivotRow, 0, pivotColumn); // dumpMatrix(); - // printf("------------ end of iteration --------------\n"); + // qDebug("------------ end of iteration --------------\n"); return true; } -- cgit v0.12