Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qDebug doesn't stream anything
Forum Updated to NodeBB v4.3 + New Features

qDebug doesn't stream anything

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 483 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Nasser AhmedN Offline
    Nasser AhmedN Offline
    Nasser Ahmed
    wrote on last edited by Nasser Ahmed
    #1

    Hello;
    I have just start learning Qt using Qt Creator V4.13 and Qt V5.15.1, when I use qDebug(), qInfo(), qWarning() and qCritical() it doesn't show any thing in the application output.
    [Edit]
    I have checked 'run in terminal' and then clean and rebuild project, it now runs with "qtcreator_process_sub" with the required output of qDebug.

    .pro file

    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    CONFIG += c++11
    
    # You can make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES += \
        main.cpp \
        mainwindow.cpp
    
    HEADERS += \
        mainwindow.h
    
    FORMS += \
        mainwindow.ui
    
    TRANSLATIONS += \
        ToDo_ar_EG.ts
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    MainWindow.h file
    

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>

    QT_BEGIN_NAMESPACE
    namespace Ui { class MainWindow; }
    QT_END_NAMESPACE

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    private slots:
    void addTask();

    private:
    Ui::MainWindow *ui;
    };
    #endif // MAINWINDOW_H

    MainWindow.cpp file
    

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "QtWidgets/QPushButton"
    #include "QDebug"
    #include <iostream>

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    connect(ui->addTaskButton, &QPushButton::clicked, this, &MainWindow::addTask);
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::addTask()
    {
    qDebug()<<"Debug button";
    qInfo()<<"Information output";
    qWarning()<<"Warning output";
    qCritical()<<"Critical output";
    }

    I have spent two days searching on Google but it all the answers were about undefine QT_NO_DEBUG_OUTPUT but it's defined.
    what I have tried:
    include "QtDebug" instead of "qDebug"
    create qtlogging.ini with content:-
    

    [Rules]
    .debug=true
    qt.
    .debug=false

    Tried a clean build (clean and rebuild project) after each edit
    
    specs:
    Arch Linux (System is up to date I have just updated it)
    V4.13 and Qt V5.15.1
    CMake V3.18.2
    Make V4.3
    QMake V3.1
    JonBJ 1 Reply Last reply
    0
    • Nasser AhmedN Nasser Ahmed

      Hello;
      I have just start learning Qt using Qt Creator V4.13 and Qt V5.15.1, when I use qDebug(), qInfo(), qWarning() and qCritical() it doesn't show any thing in the application output.
      [Edit]
      I have checked 'run in terminal' and then clean and rebuild project, it now runs with "qtcreator_process_sub" with the required output of qDebug.

      .pro file

      QT       += core gui
      
      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
      
      CONFIG += c++11
      
      # You can make your code fail to compile if it uses deprecated APIs.
      # In order to do so, uncomment the following line.
      #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
      
      SOURCES += \
          main.cpp \
          mainwindow.cpp
      
      HEADERS += \
          mainwindow.h
      
      FORMS += \
          mainwindow.ui
      
      TRANSLATIONS += \
          ToDo_ar_EG.ts
      
      # Default rules for deployment.
      qnx: target.path = /tmp/$${TARGET}/bin
      else: unix:!android: target.path = /opt/$${TARGET}/bin
      !isEmpty(target.path): INSTALLS += target
      
      MainWindow.h file
      

      #ifndef MAINWINDOW_H
      #define MAINWINDOW_H

      #include <QMainWindow>

      QT_BEGIN_NAMESPACE
      namespace Ui { class MainWindow; }
      QT_END_NAMESPACE

      class MainWindow : public QMainWindow
      {
      Q_OBJECT

      public:
      MainWindow(QWidget *parent = nullptr);
      ~MainWindow();
      private slots:
      void addTask();

      private:
      Ui::MainWindow *ui;
      };
      #endif // MAINWINDOW_H

      MainWindow.cpp file
      

      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      #include "QtWidgets/QPushButton"
      #include "QDebug"
      #include <iostream>

      MainWindow::MainWindow(QWidget *parent)
      : QMainWindow(parent)
      , ui(new Ui::MainWindow)
      {
      ui->setupUi(this);
      connect(ui->addTaskButton, &QPushButton::clicked, this, &MainWindow::addTask);
      }

      MainWindow::~MainWindow()
      {
      delete ui;
      }

      void MainWindow::addTask()
      {
      qDebug()<<"Debug button";
      qInfo()<<"Information output";
      qWarning()<<"Warning output";
      qCritical()<<"Critical output";
      }

      I have spent two days searching on Google but it all the answers were about undefine QT_NO_DEBUG_OUTPUT but it's defined.
      what I have tried:
      include "QtDebug" instead of "qDebug"
      create qtlogging.ini with content:-
      

      [Rules]
      .debug=true
      qt.
      .debug=false

      Tried a clean build (clean and rebuild project) after each edit
      
      specs:
      Arch Linux (System is up to date I have just updated it)
      V4.13 and Qt V5.15.1
      CMake V3.18.2
      Make V4.3
      QMake V3.1
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Nasser-Ahmed
      Everything works fine for me (without touching any qtlogging.ini, should that indeed have qt..debug=false, I don't know?), under Ubuntu with all distro-released Qts, I never compile.

      One thing: add your own qInstallMessageHandler(myMessageOutput) as per https://doc.qt.io/qt-5/qtglobal.html#qInstallMessageHandler . All qDebug()/qInfo() etc. go via that. Does that even get hit for you? If it does you have some problem with the output; it it does not you have some problem with your qDebug()s etc., such as compiled to do nothing.

      Another small thing: your Qt include #include statements should all be #include <something-no-slash>, so:

      #include <QPushButton>
      #include <QDebug>
      

      Using your "s there could be a danger if it picking up something of your own instead of the Qt system one. Correct those as shown, just in case....

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved