qDebug() output is not visible on a terminal - qt

I use UBuntu 12.04 LTS. When I run a console application using Qt Creator an output of qDebug() is not visible on a terminal (I get only an empty terminal with a cursor). How to fix that ?
Edit1 Moreover I can't stop a program using a stop button, I have to use a Force Quit option.
Edit2 Here is the code:
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
qDebug()<<"Ok";
return a.exec();
}
Edit3 Solution: Qt Creator: Run in Terminal

Related

FFmpeg on Qt Creator

I have got FFmpeg compiled using MSYS2. I have a strange issue that appeared only recently.the app crashes.
This is my main file:
#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
extern "C" {
#include <libavdevice/avdevice.h>
#include <libavformat/avformat.h>
#include <libavutil/avutil.h>
#include <libavcodec/avcodec.h>
}
int main(int argc, char *argv[])
{
//qDebug() << av_version_info();
// avdevice_register_all();
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
The program runs but crashes if I call 'avdevice_register_all()' and others FFmpeg functions,but only call 'av_version_info()' is runs, not crashes.
I don't really know how to solve this?
I have already tried to use google solving the problem,but no result.

QML application virtual keyboard behind fullscreen application

I want to use Qt virtual keyboard in my QML application. I use Qt 5.9.4 and I am on Windows 7.
I tried the Qt example called "basic", it works in "windowed" mode, but when I put the application window in full screen with
view.showFullScreen(); // instead of view.show() for windowed mode
the keyboard appears behind the application window and not above it, so it's not usable.
How to correct that?
EDIT:
Sorry, as I talk about Qt example, I thought, wrongly, that everyone had it.
Here is the code:
#include <QQuickView>
#include <QGuiApplication>
#include <QQmlEngine>
int main(int argc, char *argv[])
{
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
QGuiApplication app(argc, argv);
QQuickView view(QString("qrc:/%2").arg(MAIN_QML));
if (view.status() == QQuickView::Error)
return -1;
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.showFullScreen();
return app.exec();
}

QDesktopServices backend on linux?

What is used to open urls with QDesktopServices::openUrl(...)?
xdg-open, kopen, selmademachanism or a mix of them? I ask because it fails on a scheme where xdg-open does not.
Edit: okay its getting even more curious: The missing scheme works in debug mode, but not in release mode...
Example code:
#include <QApplication>
#include <QDesktopServices>
#include <QUrl>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QDesktopServices::openUrl(QUrl("tg://resolve?domain=imagebot"));
}

How to restart a qt application after crashing?

Is it possible to restart a qt application after its crashing? Just like those windows service which will restart on its own. If so, how could I do it? I have tried code like this:
#define RESTART_CODE 1000
int main(int argc, char *argv[])
{
int return_from_event_loop_code;
QPointer<QApplication> app;
QPointer<MainWindow> main_window;
do
{
if(app) delete app;
if(main_window) delete main_window;
app = new QApplication(argc, argv);
main_window = new MainWindow(app);
return_from_event_loop_code = app->exec();
}
while(return_from_event_loop_code==RESTART_CODE)
return return_from_event_loop_code;
}
But it is not working...
What should I do now?
create another qt application that runs your application.
#include <QApplication>
#include "QProcess"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QProcess aProcess;
QString exe = "Your process name with exact path";
QByteArray myOut;
while(1)
{
aProcess.start(exe);
//aProcess.waitForStarted();
//myOut = aProcess.readAllStandardOutput();
//printf("%s",myOut.constData());
aProcess.waitForFinished(-1);
//QString output(aProcess.readAllStandardOutput());
myOut = aProcess.readAllStandardOutput();
printf("%s",myOut.constData());
}
return a.exec();
}
this program will restart your app when it crashed or closed
You can use my open source library:
https://marketplace.qt.io/products/main-loop-wdt-for-qt-qml
It is a watchdog timer for the main loop and only works if the main loop freezes (double mutex lock, infinite loop, etc.), but it would not work in an application crash.

Error Occured while designing Dialog in Qt

The program name is GoToCell in the form I created a label and two push buttons and I wrote the code in main.cpp as follows:
#include <QtGui/QApplication>
#include<QDialog>
#include "ui_GoToCell.h"
#include "GoToCell.h"
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
Ui::GoToCell ui;
QDialog *dialog=new QDialog;
ui.setupUi(dialog);
dialog->show();
return a.exec();
}
While running it I'm getting the following errors:
GoToCell is not a member of ui
What should I do?
I think you have misspelled object name in objectName property in the GoToCell.ui form.
Change it to GoToCell. It will then execute.

Resources