Regarding the virtual keyboard in qt5 with widget application on windows - qt

I want to use QT5's virtual keyboard in my application. My code is as below:
int main(int argc, char *argv[])
{
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
...
}
But unfortunately, it doesn't work. When I move the qlineedit's input, it shows that "qrc:/QtQuick/VirtualKeyboard/content/InputPanel.qml:33:1: module "QtQuick.VirtualKeyboard" is not installed"

Related

QTableWidget with QPushbutton inside: resize problem

I'm an absolute beginner of Qt. I have the following MWE.
#include <QApplication>
#include <QTableWidget>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTableWidget table;
table.setRowCount(2);
table.setColumnCount(3);
QPushButton button("Push me");
table.setCellWidget(1, 1, &button);
table.show();
return a.exec();
}
I notice that when I resize the column of the table holding the mousebutton down the PushButton remain of the same dimension and it adjust to the correct size only when the mousebutton is released. Is this a wanted feature? How can I avoid it?
EDIT
My setups are
Qt 5.15.0 on Linux
Qt 5.15.0 via PySide2 on Linux
Qt 5.15.0 on Windows

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.

qDebug() output is not visible on a terminal

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

Resources