I have a simple program, in which I need to display japanese characters. It has a bit strange behaviour( in my opinion ), sometimes it displays character as it is, sometimes it displays it like square.
Normal/correct display
Issue observed time
My code as follows
japanesedisplay.cpp
#include "japanesedisplay.h"
#include "ui_japanesedisplay.h"
JapaneseDisplay::JapaneseDisplay(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::JapaneseDisplay)
{
ui->setupUi(this);
ui->label->setText("こんにちは");
}
JapaneseDisplay::~JapaneseDisplay()
{
delete ui;
}
main.cpp
#include "japanesedisplay.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
JapaneseDisplay w;
w.show();
return a.exec();
}
My Qt version : 5.3.2
My Platform : Ubuntu 14.04 LTS
Thanks in advance.
Related
I am making a little app in Qt Creator, and I keep getting this error/warning from qt.pointer.dispatch:
qt.pointer.dispatch: delivering touch release to same window QWindow(0x0) not QWidgetWindow(0x14ef0d570, name="MainWindowWindow")
qt.pointer.dispatch: skipping QEventPoint(id=1 ts=0 pos=0,0 scn=1063.83,670.067 gbl=1063.83,670.067 Released ellipse=(1x1 ∡ 0) vel=0,0 press=-1063.83,-670.067 last=-1063.83,-670.067 Δ 1063.83,670.067) : no target window
I'm not doing anything special with touch release (as you can see below), and the error also doesn't affect the running of the program so far as I can tell. What is the problem and how do I fix it?
main.cpp
#include "mainwindow.hpp"
#include <QApplication>
#include <QLocale>
#include <QTranslator>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTranslator translator;
const QStringList uiLanguages = QLocale::system().uiLanguages();
for (const QString &locale : uiLanguages) {
const QString baseName = "Simulization_" + QLocale(locale).name();
if (translator.load(":/i18n/" + baseName)) {
a.installTranslator(&translator);
break;
}
}
MainWindow w;
w.show();
return a.exec();
}
mainwindow.cpp
#include "mainwindow.hpp"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
I'm trying to ask for a password the user in order to access a particular section, my application is fullscreen. The problem is that when the qInputDialog appears also the unity taskbar and the application titlebar appears. I want to avoid this and keep my application fullscreen.
I'm using Qt 5.12.3 on Ubuntu 16.04
Take a look at this simple example:
Main.cpp
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.showFullScreen();
return a.exec();
}
MainWindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QInputDialog>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
bool ok;
QString text = QInputDialog::getText(this, tr("Restriscted"),
tr("Password:"), QLineEdit::Password,"",&ok, Qt::FramelessWindowHint);
if (ok && text=="pass")
{
ui->label->setText("ok");
}
}
Seems there is no solution for this at the moment and the issue depends on Unity. At the end I replaced the qInputDialog with a qStackedView page with a qLabel and a qButton on it, then I hide/show the page accordingly.
I am trying to open up my app with a child window first. I got some code that almost works, but I cannot for the life of me figure out what is wrong with it that won't let it delete old dialog windows, and when I click back into the child dialog I opened with, it glitches out and I just end back up at square one! What should I do to stop this problem?
main.cpp file
#include "mainwindow.h"
#include <QApplication>
#include "yes.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget MainWindow;
MainWindow.show();
yes popup(&MainWindow);
popup.show();
return a.exec();
}
.cpp file
#include "yes.h"
#include "ui_yes.h"
#include "mainwindow.h"
yes::yes(QWidget *parent) :
QDialog(parent),
ui(new Ui::yes)
{
ui->setupUi(this);
ui->label->setVisible(false);
}
yes::~yes()
{
delete ui;
}
void yes::on_pushButton_clicked()
{
auto no = new MainWindow();
no->show();
no->setAttribute(Qt::WA_DeleteOnClose);
no->show();
}
I am trying to make the QtVirtualKeyboard example work with QQuickWidget instead of QQuickView. For QuickView, I use the following main.cpp code, which works fine for me:
#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));
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.show();
return app.exec();
}
I run into problems, when changing to QQuickWidgets with the following implementation of main.cpp:
#include <QQuickWidget>
#include <QApplication>
#include <QQmlEngine>
int main(int argc, char *argv[])
{
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
QApplication app(argc, argv);
QQuickWidget w(QString("qrc:/%2").arg(MAIN_QML));
w.setResizeMode(QQuickWidget::SizeRootObjectToView);
w.show();
return app.exec();
}
When I hit the input fields, the virtual keyboard shows up, but when I start typing at the keyboard, I get the message "input method is not set", which seems to be related to the input method plugin. No chars appear in the input fields.
Any ideas? The QML-code didn't change between the above variants of main.cpp
BTW: I am using Linux, gcc, Qt 5.9.0, EGLFS plugin
Thanks for any suggestions!
Regards,
Patrick
Found the solution for QML looking through inputMethod documentation. Following workaround works for me:
TextArea {
...
onActiveFocusChanged: {
if(activeFocus) {
Qt.inputMethod.update(Qt.ImQueryInput)
}
}
}
Works with other controls as well.
Of course InputPanel should be defined in ApplicationWindow like this:
ApplicationWindow {
...
InputPanel {
id: inputPanel
...
}
}
I am trying to hide my QT application from taskbar? I cannot find anything in Google so I asking here.
Solution from Qt Hide Taskbar Item (Qt Hide Taskbar Item) and this->hide() is not helping.
main.cpp
#include "status_bar.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
status_bar w;
w.show();
return a.exec();
}
status_bar.cpp:
#include "status_bar.h"
#include "ui_status_bar.h"
#include <stdlib.h>
#include <QTime>
#include <QTimer>
#include <QApplication>
#include <QDesktopWidget>
status_bar::status_bar(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::status_bar)
{
ui->setupUi(this);
setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
resize(QApplication::desktop()->width(),36);
ui->time->move(QApplication::desktop()->width()-ui->time->size().width(),10);
ui->username->setText(getenv("USER"));
timeupdate = new QTimer(this);
connect(timeupdate, SIGNAL(timeout()),
this, SLOT(UpdateClock()));
timeupdate->start(100);
}
void status_bar::UpdateClock()
{
ui->time->setText(QTime::currentTime().toString("HH:mm"));
}
status_bar::~status_bar()
{
delete ui;
}
EDIT:
With code like this window is empty.
class MyWindowWidget : public QWidget
{
public:
MyWindowWidget(QWidget *parent)
: QWidget(parent, Qt::Dialog)
{
}
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
status_bar window;
MyWindowWidget widget(&window);
widget.show();
return app.exec();
}
Solved by using Qt::Tool flag.
Qt::Tool flag has other problems for me, like this widget/windows is hidden when its state becomes inactive.
I would recommend you to use Qt::ToolTip