In the image you can see that the HWR button is enabled(green) but the input panel to write using mouse pointer is not comingI am trying to run handwriting recognition example(basic.pro) provided by qt.
The application is getting launched with qt virtual keyboard but im unable to see the HWR icon.
Can anyone help me on how to open handwriting recognition in this example?
I have attached the screenshot of the application.
TEMPLATE = app
TARGET = basic
QT += qml quick quickcontrols2 xml
SOURCES += main.cpp
CONFIG += link_pkgconfig disable-desktop handwriting lipi-toolkit
static {
QT += svg
QTPLUGIN += qtvirtualkeyboardplugin
}
target.path = $$[QT_INSTALL_EXAMPLES]/virtualkeyboard/basic
INSTALLS += target
RESOURCES += \
demo.qrc
OTHER_FILES += \
Basic.qml \
basic-b2qt.qml \
content/AutoScroller.qml \
content/HandwritingModeButton.qml \
content/TextArea.qml \
content/TextField.qml \
disable-xcb {
message("The disable-xcb option has been deprecated. Please use disable-desktop instead.")
CONFIG += disable-desktop
}
disable-desktop|android-embedded|!isEmpty(CROSS_COMPILE)|qnx {
DEFINES += MAIN_QML=\\\"basic-b2qt.qml\\\"
} else {
DEFINES += MAIN_QML=\\\"Basic.qml\\\"
}
In the image you can see that the HWR button is enabled(green) but the input panel to write using mouse pointer is not coming
The handwriting button is above the keyboard to the right.
Related
For some reason I am unable to load my plugins anymore, although it has worked previously. I have a plugin loader code in my MainWindow, which is supposed to load every .dll found in a specific folder. The MainWindow Code contains the following:
Interface
#ifndef PLUGININTERFACE_H
#define PLUGININTERFACE_H
#include <QtPlugin>
// forward declarations
class MainWindow;
struct P3DData;
class PluginInterface
{
public:
virtual bool createPublisher(MainWindow*, P3DData*) = 0;
};
#define PLUGIN_INTERFACE_iid "PluginInterface"
Q_DECLARE_INTERFACE(PluginInterface, PLUGIN_INTERFACE_iid)
#endif // PLUGININTERFACE_H
loadPlugins()
bool MainWindow::loadPlugins()
{
QDir pluginsDir(qApp->applicationDirPath());
pluginsDir.cd("plugins");
const auto entryList = pluginsDir.entryList(QDir::Files);
for(const QString &fileName : entryList)
{
QString dllPath = pluginsDir.absoluteFilePath(fileName);
QPluginLoader* loader = new QPluginLoader(dllPath);
loaderList.push_back(loader);
QObject *plugin = loader->instance();
if (plugin)
{
pluginList.push_back(qobject_cast<PluginInterface *>(plugin));
pluginList.last()->createPublisher(this, simDataPtr);
pluginCount++;
continue;
}
else
{
qDebug() << "[PluginLoader] '" + fileName + "': " + loader->errorString();
delete loaderList.takeLast();
}
}
}
Besides my MainWindow, there is another subdir in my project, which is the plugin "Position". The plugin is deployed into the correct "plugins" folder, which the loadPlugin() method from the MainWindow iterates through. The plugin uses following code to implement the interface:
#include <QObject>
#include "MainWindow.h"
class PositionPublisher : public QObject, PluginInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "PluginInterface")
Q_INTERFACES(PluginInterface)
public:
PositionPublisher();
~PositionPublisher();
bool createPublisher(MainWindow* _window, P3DData* _simDataPtr) override;
//...
};
When trying to run loadPlugins() now, it checks the correct Position.dll file but the "if(plugin)" part returns false and loader->errorString() is executed giving the following error:
[PluginLoader] 'Position.dll': Cannot load library
F:\DEV\build\simNET\bin\plugins\Position.dll: Cannot find the
specified module.
I have already checked and tried the following:
the Plugins folder actually contains the Position.dll file
both projects (MainWindow and Plugin) are built in release mode
the dependencies of the plugin (two libs) exist and the specified path in the pro file is correct
.pro file of plugin:
QT += widgets
TEMPLATE = lib
CONFIG += c++11
CONFIG += plugin
CONFIG += release
SOURCES += \
Position.cpp \
PositionPubSubTypes.cpp \
PositionPublisher.cpp
HEADERS += \
Position.h \
PositionPubSubTypes.h \
PositionPublisher.h
DISTFILES += \
Position.idl
INCLUDEPATH += ../../application
TARGET = $$qtLibraryTarget(Position)
DESTDIR = ../../bin/plugins
INCLUDEPATH += "F:/DEV/prog/FastRTPSv1.5/include"
DEPENDPATH += "F:/DEV/prog/FastRTPSv1.5/include"
LIBS += -L"F:/DEV/prog/FastRTPSv1.5/lib/x64Win64VS2015" -lfastrtps-1.5
PRE_TARGETDEPS += F:/DEV/prog/FastRTPSv1.5/lib/x64Win64VS2015/fastrtps-1.5.lib
INCLUDEPATH += 'F:/Programme/Prepar3D v4/SDK/inc/SimConnect'
DEPENDPATH += 'F:/Programme/Prepar3D v4/SDK/inc/SimConnect'
LIBS += -L'F:/Programme/Prepar3D v4/SDK/lib/SimConnect' -lSimConnect
PRE_TARGETDEPS += 'F:/Programme/Prepar3D v4/SDK/lib/SimConnect/SimConnect.lib'
Does anyone have an idea why it does not load the plugin??
Qt plugin loader is trying to tell you that a Qt module used in your plugin doesn't exist so first you need to check which Qt modules your plugin depends on then,
If you're trying to run the application from Qt Creator itself, and it gives you this error, then maybe the DLL file got deleted for some reason or you're trying to use the plugin with a Qt version that doesn't have its needed modules. (for example, Qt6 doesn't contain the QtSerialPort module but Qt5 did (at the time of writing this)).
If you're trying to run the application directly outside Qt Creator then you need to copy the required module's dll file into your applications root directory.
I am working on some project using phyBoard Wega with its SDK with Qt 5.8. Project also relies on QtUPnP library and when I try to create new QtUPnP::CControlPoint object, I get illegal instruction:
Library itself is linked into main project in a static fashion, here are contents of .pro file:
CONFIG += c++11
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Refer to the documentation for the
# deprecated API to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
audiocontentsmodel.cpp \
audiocontentsrecord.cpp \
audiodevicerecord.cpp \
audiodevicesmodel.cpp \
audioinputrecord.cpp \
audioinputsmanager.cpp \
audioinputsmodel.cpp \
configurationmanager.cpp \
i2cbusmanager.cpp \
main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
audiocontentsmodel.h \
audiocontentsrecord.h \
audiodevicerecord.h \
audiodevicesmodel.h \
audioinputrecord.h \
audioinputsmanager.h \
audioinputsmodel.h \
coloreddebug.h \
configurationkeys.h \
configurationmanager.h \
configurationsections.h \
customtypes.h \
defaultconfiguration.h \
i2cbusmanager.h \
threadnames.h
unix:!macx: LIBS += -L$$PWD/../upnp/ -lqtupnp
INCLUDEPATH += $$PWD/../upnp
DEPENDPATH += $$PWD/../upnp
unix:!macx: PRE_TARGETDEPS += $$PWD/../upnp/libqtupnp.a
Why do I get crash when I try to use library?
ADDENDUM 1: I have also tried to include library as dynamic (.so file), same result.
ADDENDUM 2: If I recompile library and project itself for Desktop Qt (5.14, Ubuntu 19.10), the app works fine.
ADDENDUM 3: If I analyze target (final binary) file UserConsole, I get:
user#bohr:~/Projects/NoordungMkI/Software/UserConsole$ file UserConsole
UserConsole: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=82aaff1b9db2061cbba1c59a3bddd8a6d2d82d80, with debug_info, not stripped
Should be here staticly linked, because the library is staticly linked?
I have followed the code with gdb and the library tried to set SSL configuration via:
CHTTPServer::CHTTPServer (QHostAddress const & address, quint16 port, QObject* parent) :
QTcpServer (parent), m_done (false),
m_httpsBufferSize (4096),
m_httpsReadDataTimeout (1),
m_httpsReadDataWaitingRetry (20000)
{
bool success = listen (address, port);
if (success)
{
m_httpsRequest.setSslConfiguration (QSslConfiguration::defaultConfiguration ());
connect (this, &CHTTPServer::httpValidReadMessage, this, &CHTTPServer::sendResponse, Qt::QueuedConnection);
connect (this, &CHTTPServer::streamingReady, this, &CHTTPServer::streamBlock, Qt::QueuedConnection);
m_done = true;
}
}
and I have commented then the line with SSL configuration:
CHTTPServer::CHTTPServer (QHostAddress const & address, quint16 port, QObject* parent) :
QTcpServer (parent), m_done (false),
m_httpsBufferSize (4096),
m_httpsReadDataTimeout (1),
m_httpsReadDataWaitingRetry (20000)
{
bool success = listen (address, port);
if (success)
{
// m_httpsRequest.setSslConfiguration (QSslConfiguration::defaultConfiguration ());
connect (this, &CHTTPServer::httpValidReadMessage, this, &CHTTPServer::sendResponse, Qt::QueuedConnection);
connect (this, &CHTTPServer::streamingReady, this, &CHTTPServer::streamBlock, Qt::QueuedConnection);
m_done = true;
}
}
and the app works now. This is not the best way of resolving the problem (I think IT IS BAD ONE) and I will do refix later.
I have a problem to compile a project Qt/Android, because of the use of some static libs(windows .lib). The current situation of .pro file is this:
android {
QT += androidextras
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/native
ANDROID_DEPLOYMENT_DEPENDENCIES = \
$$PWD/../../../libraries/protobuf/vsprojects/Release/libprotobuf.lib \
$$PWD/../../../libraries/log4qt/lib/liblog4qtd.lib
}
However this not solve the problems, i not know what make =/
It seems to be QMediaPlayer doesn't read tags of playlist files without of executing method play() of current track. Is there a way to force read tags from QMediaPlayer playlist without of playing it?
Sorry if this if a noob question, but I spent a lot of time for searches.
Thanks
Don't waste your time to use QMediaPlayer to read tags (this solution works good, but difficult for many files in list), simply use TagLib or another open-source library.
For example, 3 simple steps to use TagLib in Qt:
1.Compile taglib from source:
$ pwd
/home/user/taglib-1.9.1
$ cmake .
$ make
It's enough to deploy working instance of tag library. Really :)
2.Include headers and library in your project, simply add this or your custom path to project file:
unix:!macx: LIBS += -L$$PWD/3rdparty/taglib-1.9.1/taglib/ -ltag
INCLUDEPATH += $$PWD/3rdparty/taglib-1.9.1/taglib/Headers
DEPENDPATH += $$PWD/3rdparty/taglib-1.9.1/taglib/Headers
3.Use it, very simple function to get media tags from files, in this example artist and title of track:
#include <fileref.h>
#include <tag.h>
QString gettags(QString mediafile){
QString string;
TagLib::FileRef file(mediafile.toUtf8());
TagLib::String artist_string = file.tag()->artist();
TagLib::String title_string = file.tag()->title();
QString artist = QString::fromStdWString(artist_string.toWString());
QString title = QString::fromStdWString(title_string.toWString());
string = artist + " - " + title;
return string;
}
For the current QT/OSX, use this project file snippet (change paths for your system)
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.11
LIBS += -L/Users/sir/prg.qt/TuneMerge/taglib-1.11.1/taglib/ -ltag -lz
INCLUDEPATH += /Users/sir/prg.qt/TuneMerge/taglib-1.11.1/
INCLUDEPATH += /Users/sir/prg.qt/TuneMerge/taglib-1.11.1/taglib/
INCLUDEPATH += /Users/sir/prg.qt/TuneMerge/taglib-1.11.1/taglib/toolkit/
DEPENDPATH += /Users/sir/prg.qt/TuneMerge/taglib-1.11.1/taglib
I've just installed Qt 4.7.4 and trying to make a simple Qt App that uses Qt DLL. I added export/import in a class in DLL through ifdef as usual but when compiling App I het unresolved references. I also set that App depends on the DLL.
Here are the main files:
Lib.pro
QT -= gui
TARGET = Lib
TEMPLATE = lib
DEFINES += LIB_LIBRARY
SOURCES += lib.cpp
HEADERS += lib.h\
Lib_global.h
symbian {
MMP_RULES += EXPORTUNFROZEN
TARGET.UID3 = 0xE10C4E25
TARGET.CAPABILITY =
TARGET.EPOCALLOWDLLDATA = 1
addFiles.sources = Lib.dll
addFiles.path = !:/sys/bin
DEPLOYMENT += addFiles
}
unix:!symbian {
maemo5 {
target.path = /opt/usr/lib
} else {
target.path = /usr/lib
}
INSTALLS += target
}
App.pro
QT += core gui
TARGET = App
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
lib.h
#ifndef LIB_H
#define LIB_H
#include "Lib_global.h"
#include <QString>
class LIBSHARED_EXPORT Lib {
public:
Lib();
~Lib();
QString Hello(QString a);
};
#endif // LIB_H
Lib_global.h
#ifndef LIB_GLOBAL_H
#define LIB_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(LIB_LIBRARY)
# define LIBSHARED_EXPORT Q_DECL_EXPORT
#else
# define LIBSHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // LIB_GLOBAL_H
What's wrong with this code? Why is it unresolved reference?
In App I just include "../Lib/lib.h" and try to use the class.
What looks to be missing is the link between your application and your dynamic library.
I usually do something like this for my desktop (linux) apps:
INCLUDEPATH += ./include
LIBS += -L./lib -lLib
Where:
INCLUDEPATH defines the path to where your shared library .h files are located.
LIBS defines the path to where your built library is.
You can find the relevant documentation here: QMake - Declaring Other Libraries
Updated:
I was able to build the project (Linux Qt v4.7.4) and link to the library using the code you posted. I will try to clarify as my response may not be entirely clear.
The INCLUDEPATH and LIBS variables must be added to the App.pro file.
For the linker to properly find the library the paths must be adjusted to the paths you are using for your project:
LIBS += -L PATH -l LIBNAME
Supposing your folder structure is similar to the following:
Project
|_ Lib (your sharded library project files)
|_ App (your application project files)
You would adjust the variables like so:
INCLUDEPATH += ../Lib
LIBS += -L../Lib -lLib
Note that you link differently depending on your platform, you can do something like this to cover Windows and Linux:
unix {
INCLUDEPATH += ../Lib
LIBS += -L../Lib -lLib
}
win32 {
INCLUDEPATH += ../Lib
LIBS += ../Lib.lib
}