QT qDebug() does not print anything in IDE console - c++

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();
}
...

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

Related

Qt3DWindow performance issue on Ubuntu 17.10

My problem is that I want to create a Qt3DWindow which I embed in my program using QWidget::createWindowContainer.
I now upgraded to Ubuntu 17.10 but as soon as I add the container widget my CPU load goes up to 100% constant.
This worked already under Ubuntu 16.04 and Windows.
Does anyone know this issue or maybe even have a solution? Or do I have to downgrade to Ubuntu 16.04 again?
A minimally working example is creating a new project in Qt Creator and selecting Qt Widgets Application and, finally, replacing the code in the mainwindow.cpp with the following:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QHBoxLayout>
#include <Qt3DExtras/Qt3DWindow>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->centralWidget->setLayout(new QHBoxLayout());
Qt3DExtras::Qt3DWindow *window = new Qt3DExtras::Qt3DWindow;
QWidget *widget = QWidget::createWindowContainer(window);
ui->centralWidget->layout()->addWidget(widget);
}
MainWindow::~MainWindow()
{
delete ui;
}
Now add 3dextras to QT += core gui in the .pro file of your project and run it. This produces the high CPU load on my machine.

Simple Qt project with openCV instantly crash

I try to use openCV in a Qt project. But my release build instantly crash on launch if I link the release libs of openCV. Debug libs allow the programm to start but the application crashes when I try to use openCV functions (it is known that mixing release/debug in openCV causes some crash).
So I made a simple project and it won't even launch. Both release and debug build crashes and using debugger causes a small window saying 'unexpected CDB exit'.
Here are the source.
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = test_openCV
TEMPLATE = app
#flags to generate a .map file
QMAKE_LFLAGS_RELEASE +=/MAP
QMAKE_LFLAGS_RELEASE += /debug
SOURCES += main.cpp\
MainWindow.cpp
HEADERS += MainWindow.h
FORMS += MainWindow.ui
INCLUDEPATH += $$PWD
INCLUDEPATH += "D:/openCV/build/include"
#Switching between handbuild and the build I downloaded have no effect.
#I am sure the path are good. Quadra checked.
#LIBS += -L"D:/openCV/build/x64/vc11/lib"
LIBS += -L"D:/openCV/hand_build/lib/Release"
LIBS += -L"D:/openCV/hand_build/lib/Debug"
#disables the "fopen not secure" warning in openCV.
DEFINES += _CRT_SECURE_NO_WARNINGS
win32:CONFIG(release, debug|release): LIBS += -lopencv_core2413 -lopencv_highgui2413 -lopencv_imgproc2413
else:win32:CONFIG(debug, debug|release): LIBS += -lopencv_core2413d -lopencv_highgui2413d -lopencv_imgproc2413d
main.cpp:
#include "MainWindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
MainWindow.h:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <opencv/cv.h>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
and MainWindow.cpp:
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include "opencv2/core.hpp"
#include "opencv2/highgui.hpp"
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
//Removing this line will causes the program to start normally (guess it won't link the libs if nothing from openCV is used).
cv::Mat image;
}
MainWindow::~MainWindow()
{
delete ui;
}
What I get when launching app:
Starting D:\Colin\build_test_openCV\release\test_openCV.exe...
program suddenly ended
D:\Colin\build_test_openCV\release\test_openCV.exe crashed
I work on Windows 7 / MSCV2012 openGL 64bits / Qt 5.2.1 openGL.
Does anyone see a mistakes I could have made?
I have a similar setup as yours and was getting the exact same problem. The issue was that the path to the corresponding dlls was not defined. These dlls:
opencv_core2411.dll
opencv_highgui2411.dll
opencv_imgproc2411.dll
should be in D:/openCV/hand_build/bin/ (or maybe D:/openCV/hand_build/bin/Release/). Adding another line:
LIBS += -L"D:/openCV/hand_build/bin/Release/"
should work.
I just had a similar issue. The program was crashing because it could not find the appropriate DLL at runtime. Adding the OpenCV directories to my Windows PATH fixed the problem for me.
All items in your build must have been built using the same Visual Studio version, that means:
The Qt install you're using.
OpenCV.
Your code.
Most likely at least one of the above was not built using the same compiler. If OpenCV is linked against Qt, it must have been built against a binary-compatible version of Qt, too.

Specific websites throwing an exception in QWebView

While running my code I am getting a Write Access Violation Exception when it tries to use QWebView:
Minimal compilable code for reproducing the error
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWebKitWidgets/QWebView>
#include <QUrl>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QWebView *wv = new QWebView(this);
wv->load(QUrl("http://steamcommunity.com/"));
setCentralWidget(wv);
}
MainWindow::~MainWindow()
{
delete ui;
}
The pro file also includes webkitwidgets and network:
QT += core gui webkitwidgets network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MyApp
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
Error Hints
The error I get looks like this:
ASSERTION FAILED: leftSide->category() != CalcOther && rightSide->category() != CalcOther
css\CSSCalculationValue.cpp(290) : WebCore::CSSCalcBinaryOperation::create
1 0354A5B7
2 02E58E41
3 02E59520
...
I can't provide a stack trace because the error is in one of the Qt files, but here is the disassembly:
The error only occurs on specific webpages (e.g. steamcommunity.com) but not others. Is it possible that some sites just break Qt's API?
compiler: MSVC2013 x86
Qt version: Qt 5.5.0
Turns out that this error is actually a Qt bug.
Its status can be viewed here: Qt Bug Report
Using the new Qt WebEngine Widgets module worked great as a replacement for me.

Qt Widgets FullScreen Margin

I want to create a program that loads google in literally full screen, so I achieved opening my qt program in full screen using w.showFullScreen(); and it works perfectly, however when I add the QWebView and set it to centralWidget like this:
but when I run the program, I get some margins on the sides of the window, in other words the QWebView isn't literally in fullScreen harmoniously with the window which is, it looks like this:
I don't think my code is mistaken but here it is
untitled.pro:
#-------------------------------------------------
#
# Project created by QtCreator 2015-02-07T21:25:42
#
#-------------------------------------------------
CONFIG += release
QT += core gui
QT += webkitwidgets
main.cpp
w.showFullScreen();
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWebKitWidgets>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->webView->load(QUrl("http://www.google.com"));
}
MainWindow::~MainWindow()
{
delete ui;
}
Thank you.
Your central widget have a layout. It's possible that you have layoutLeftMargin, layoutRightMargin, layoutTopMargin, layoutBottomMargin with others values than 0 got in you QtDesigner click on your central widget and at the down of you properties set the margins to 0.

Cannot #include <QWebView> using QtCreator

I have read a lot trying to figure this out. I am using QtCreator on Ubuntu 13.10.
.pro:
#-------------------------------------------------
#
# Project created by QtCreator 2014-03-02T09:50:03
#
#-------------------------------------------------
QT += core gui
QT += webkit
QT += webkit webkitwidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = AndroidDecompiler
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
MAIN
#include "mainwindow.h"
#include <QApplication>
#include <QtWebKit>
#include <QWebView>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
QWebView view;
view.show();
view.setUrl(QUrl("http://google.com"));
return a.exec();
}
Here is error ':-1: error: cannot find -lsqlite3'
I think it is due to not being able to include webview. Is their any suggestions?
You could install the sqlite3 library as follows:
sudo apt-get install sqlite3 libsqlite3-dev
I think you can replace the header:
#include <QtWebKit>
#include <QWebView>
with:
#include <Qt/QtGui>