QML application virtual keyboard behind fullscreen application - qt

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

Related

Regarding the virtual keyboard in qt5 with widget application on windows

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"

QT - SplashScreen implementation

I have an embedded Qt application for Linux which has the following startup code:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// Startup actions neeeded to display AppView correctly
// Black screen is shown for several seconds
// ...
QQuickView AppView;
AppView.setSource(QUrl(QStringLiteral("main.qml")));
AppView.resize(480, 800);
AppView.show();
return app.exec();
}
I'd like to remove the black screen shown before AppView and to display QML animation
instead of it.
I see two possible options here but non of them is clear. Could you please advice
which one of them is more correct and also comment/answer the questions in each.
Option 1: To display QSplashScreen at the beginnning of main().
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QSplashScreen *splash = new QSplashScreen();
splash->show();
// Startup actions neeeded to display AppView correctly
// Black screen is shown for several seconds
// ...
}
The question here is what API to use to attach QML animation to QSplashScreen?
QSplashScreen inherits from QWidget, and so as I understand, no API like QQuickWidget::setSource() can be used.
Option 2: To display another QQuickView at the beginnning of main() with attached QML animation.
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQuickView SplashView;
SplashView.setSource(QUrl(QStringLiteral("SplashScreen.qml")));
SplashView.resize(480, 800);
SplashView.show();
app.exec();
// Startup actions neeeded to display AppView correctly
// Black screen is shown for several seconds
// ...
QQuickView AppView;
AppView.setSource(QUrl(QStringLiteral("main.qml")));
AppView.resize(480, 800);
AppView.show();
}
The question here is how to to close the SplashView and to display AppView on top of it?
Thanks
Option 1 is not good idea. You should not mix Qt Quick and Qt Widgets applications.
QApplication::exec() starts event loop of main gui thread and never returns until application is quit. Although I do not like your way of handling splash screen, in this case, you can use something like this.
QGuiApplication app(argc, argv);
QQuickView view;
view.setSource(QUrl("SplashScreen.qml"));
view.resize(640, 480);
view.show();
QTimer::singleShot(2000,&view,[&view](){
view.close();
view.setSource(QUrl("main.qml"));
view.show();
});
return app.exec();
I used timer to simulate "actions to display app correctly" . You should replace that part with your class, which does actions. When actions are done that class can emit a signal in receiving slot you can close current view which shows splash screen and show main app.

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

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.

How to create a correct exit button in qt

I'm trying to create an exit button that correctly closes the GUI I have made in QT. I have tried doing this in the following way:
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
int window_width = QApplication::desktop()->width();
int window_height = QApplication::desktop()->height();
MainWindow w;
QPushButton * quit_btn = new QPushButton;
quit_btn->setParent(w.centralWidget());
quit_btn->setGeometry(window_width-50,12,32,32);
QObject::connect(quit_btn,SIGNAL(clicked()),qApp,SLOT(quit()));
w.resize(window_width,window_height);
w.show();
return a.exec();
}
Unfortunately when I push the button, the debugger gives an error:
Invalid address specified to RtlFreeHeap( 003E0000, 0028F950 )
Can anybody point me in the right direction?
Connect the button's clicked() signal to your main window's close() slot. That way things are cleaned up properly.

Resources