0

I need qDebug(), qInfo(), qWarning(), qCritical, or qFatal() to print information to the QTCreator console. Now nothing of it doesn't work. I install QTCreator from repository.

Editing the qtlogging.ini didn't change anything. I added all possible tags to the. pro file.

Qt 5.15.2

Linux user 5.13.15-1-MANJARO #1 SMP PREEMPT x86_64 GNU/Linux

*.pro file:

QT       += core gui sql

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11
CONFIG += debug
CONFIG += console

*.h file:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QDebug>
#include <QComboBox>
#include <QString>
#include <QtSql>

...

*.cpp file:

#include "mainwindow.h"
#include "ui_mainwindow.h"


MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    qDebug() << "Check";
    ui->setupUi(this);
    load();
}
...
drescherjm
  • 10,365
  • 5
  • 44
  • 64
qreodium
  • 33
  • 6
  • 1
    Are you sure the constructor of your main window is actually called? Have you tried calling `qDebug()` within your actual `main`? If you add some `cout` right after the `qDebug()`, does that one work? And `cerr`? – Aziuth Sep 22 '21 at 14:54
  • @Azimuth, I tried cout and qDebug in one function. Cout print all information only after the program is closed, while qDebug() doesn't print anything – qreodium Sep 24 '21 at 03:46
  • Try them in main.cpp if something related to qtCreator settings , in main.cpp you should have this problem. If not you should add all your program you have mistakes there. – Parisa.H.R Sep 24 '21 at 05:38
  • 1
    @reodium Question, did you call it like `std::cout << "my text" << std::endl`, that is especially with the `endl`? Want to make sure that you flushed the text (note: `\n` doesn't automatically flush). Because if you did, and it still printed only after you closed the program, then either the message code is only executed then (like in a destructor) or something is very very wrong. – Aziuth Sep 24 '21 at 10:21
  • Another idea: when you execute within the creator, you have several tabs at the bottom. It might be that you are simply in the wrong tab, like say the compilation message tab, and that this tab is closed when you close the program, switching the active tab to the actual output. – Aziuth Sep 24 '21 at 10:23
  • In any case, you should strongly simplify your code for this test. Omit usage of your main window class and reduce your main to a very simple Hello World!, with several output methods (`cout`, `qDebug()`, `printf()`...) – Aziuth Sep 24 '21 at 10:24
  • @Aziuth, thank you for your advice. With `std::cout << "my text" << std::endl;` everything is fine.It is printed while the program is running. But not qDebug() and qInfo(). I create an empty project and put cout and qdebug () in main.cpp . Only cout works. – qreodium Sep 25 '21 at 06:53
  • `CONFIG += console` is set? Have you rebuild the project after setting it completely (including running qmake anew, delete your `Makefile` when in doubt)? Can you locate the file `qtlogging.ini` associated with your project and tell us which values with "debug" in their name are set true? If all of that fails, try the line `QLoggingCategory::defaultCategory()->setEnabled(QtDebugMsg, true);` before using `qDebug()`. – Aziuth Sep 25 '21 at 09:42
  • On older version of QT everything works fine. There may have been some errors during the installation. – qreodium Oct 07 '21 at 15:30

1 Answers1

0

that happens because you set CONFIG += console and maybe you didn't uncheck this :

enter image description here

uncheck Run in Terminal.

Parisa.H.R
  • 3,303
  • 3
  • 19
  • 38
  • I delete `CONFIG += console` and checkbox was unchecked. To check, I turned on this option, now when the program starts, a console appears in which qDebug () prints, but this is inconvenient and still does not work in the IDE – qreodium Sep 24 '21 at 03:52
  • It's strange. try std::cout instead of qDebug and check it happens again or not. – Parisa.H.R Sep 24 '21 at 05:32
  • Don't delete what you write in .pro , just uncheck that check box and try again. – Parisa.H.R Sep 24 '21 at 05:34