I have problems loading the built-in plugins for iconengines for a deployed application. Below is a minimal program to show the problem. It is not exactly the same, because Qt scans the plugin directories at start and registers it according to the file suffix, but I hope when I can get the minimal program to run, then the automatic scanning works, too.
main.cpp:
#include <QCoreApplication>
#include <QPluginLoader>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QPluginLoader loader("C:/Qt/5.15.1/msvc2019_64/plugins/iconengines/qsvgicon.dll");
if (loader.load()) {
qDebug() << "load ok";
} else {
qDebug() << "load failed";
}
return a.exec();
}
and PluginTest.pro:
QT -= gui
CONFIG += c++11 console
CONFIG -= app_bundle
SOURCES += main.cpp
When I start it from the Qt Creator IDE, version 4.13.1, with Visual Studio 2019, 64 bit compiled, it prints "load ok". Now I do this from a "x64 Native Tools Command Prompt for VS 2019" command prompt in the project directory:
set PATH=%PATH%;C:\Qt\5.15.1\msvc2019_64\bin
mkdir deploy
copy release\PluginTest.exe deploy
windeployqt --release release\PluginTest.exe --plugindir deploy\QtPlugins
When I start PluginText.exe from the command prompt in the deploy directory, I get the output "load failed".
Additional information: when I set set qt_debug_plugins=1 and start the real application, I see these errors:
QFactoryLoader::QFactoryLoader() checking directory path "C:/projects/deploy/QtPlugins/iconengines" ...
QFactoryLoader::QFactoryLoader() looking at "C:/projects/deploy/QtPlugins/iconengines/qsvgicon.dll"
"Failed to extract plugin meta data from 'C:/projects/deploy/QtPlugins/iconengines/qsvgicon.dll'"
not a plugin
The qsvgicon.dll file is identical to "c:\Qt\5.15.1\msvc2019_64\plugins\iconengines\qsvgicon.dll".
I found the problem. It used some other Qt DLLs from the path when starting the application. This fixed it:
xcopy /y c:\Qt\5.15.1\msvc2019_64\bin\*.dll deploy
Related
I am learning Qt and running examples from Qt SDK 5.9.1. I run the code below and write inside QTextEdit but no text appears. Cursor moves as I write but no text is shown. Window title text is shown. I added addApplicationFont and setFont calls below I found from web to the sample but it didn't help.
#include <QtWidgets>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QFontDatabase::addApplicationFont("://Ubuntu-R.ttf");
app.setFont(QFont("Ubuntu", 11, QFont::Normal, false));
QTextEdit textEdit;
textEdit.show();
return app.exec();
}
I am on Ubuntu 16.04 and run following commands on bash to make executable:
qmake -makefile
make
./part1
I want the app to use the default Ubuntu system font. I learned that Qt uses fontconfig for fonts but I don't know how to trace the issue.
Edit
I thought QFontDatabase::addApplicationFont("://Ubuntu-R.ttf") call referenced system font but instead it is referencing font app resource file. I don't have resource file so obviously it won't work.
.pro file is below(unmodified sample file):
QT += widgets
SOURCES = main.cpp
# install
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/tutorials/gettingStarted/gsQt/part1
INSTALLS += target
I tried to get system font using QFontDatabase but it didn't work:
app.setFont(QFontDatabase::systemFont(QFontDatabase::GeneralFont));
This doesn't do anything with any of enum values including QFontDatabase::GeneralFont
QFontDatabase database;
QStringList fam = database.families();
fam size is zero.
I will try to use embedded font next.
I don't know the exact reason of the problem but the reason was not configuring fontconfig dependency properly before building qt. I solved it by reconfiguring and recompiling qt again. You can find more details at qt forum.
I am trying to run a basic console application (developed in Qt) in docker for windows. Development environment is windows 10, compiler VC2015, 32bit Application.
It is hello world and idea was to find the issues, before I try to port the actual application.
The code is simplest c++ code:
#include <QCoreApplication>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
std::cout<<"Hello world";
return a.exec();
}
The Dockerfile is:
# Comment:
#It needs a Microsoft environment to run
FROM microsoft/nanoserver:latest
#Create a folder inside the home folder in the Container Operating System
RUN mkdir -p C:\HelloWorld
#Copy the excutable from this folder to the folder inside the Container
Operating System.
COPY . /HelloWorld/
#Run the application inside the container operating system.
CMD ["C:\\HelloWorld\\docker_HelloWorld.exe"]
My expected end result was a console/shell output of "Hello world". But I get nothing. Can someone point out what is missing?
Thanks.
I suspect that nanoserver images only supports x64 applications, if possible please build your application as x64 and run it inside the nanoserver with its dependencies.
If not possible to build as x64, then you can use windowsservercore containers to run the x86 applications.
You should copy the dependency assemblies with that application, other wise it will not work.
On Windows 7 I installed qt creator and now I am trying to connect to the oracle database. I installed oracle client and plsql/developer and everything works fine. In qt creator I have error:
QsqlDatabase: QOCI driver not loaded
This qt documentation does not work for me. Is it clear tutorial how to do it on different platforms and situations?
Ok. I found solution.
Documentation says
set INCLUDE=%INCLUDE%;c:\oracle\oci\include
set LIB=%LIB%;c:\oracle\oci\lib\msvc
cd %QTDIR%\src\plugins\sqldrivers\oci
qmake oci.pro
nmake
If you are not using a Microsoft compiler, replace nmake with make in
the line above.
but make or nmake didn't work for me. Because I have not installed Microsoft Visual c++ on my machine.
I made instruction how to do this:
At first don't forget to install qt sources. During the installation check Sources checkbox.
then download and install oracle client win32_11gR2_client.zip. choose Runtime option during installation.(even if you are using 64 bit os download 32 bit version on oracle client). It creates c:\app\user\product\client_1... directory
then open qt minGW command line(start ->all peograms -> qt[version] -> [version] -> MinGW [version] -> Qt [version] for Desktop MinGW [version]) and move to the oci source folder:
cd C:\Qt\Qt[version]\[version]\Src\qtbase\src\plugins\sqldrivers\oci
then as documentation says include OCI(Oracle call interface) path and library:
set INCLUDE=%INCLUDE%;c:\app\user\product[version]\client_1\oci\include
set LIB=%LIB%;c:\app\user\product[version]\client_1\oci\lib\msvc
5.compile oci driver by executing these two lines:
qmake oci.pro
mingw32-make
it will creates two .dll files for you qsqloci.dll(release version) and qsqlocid.dll(debug version)
last step is to copy these two files into qtcreator installation folder.
go to the:
C:\Qt\Qt[version]\[version]\Src\qtbase\plugins\sqldrivers
and copy these files into:
C:\Qt\Qt[version]\[version]\mingw[version]\plugins\sqldrivers
and you are ready to go. to check connection try this code:
#include <QCoreApplication>
#include <QtSql>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QSqlDatabase db = QSqlDatabase::addDatabase("QOCI");
db.setHostName("MY_IP_OR_HOST_NAME");
db.setDatabaseName("XE");
db.setUserName("test");
db.setPassword("test_password");
if (!db.open())
{
qDebug() << db.lastError().text();
}
else{
qDebug() << "Wow opened";
}
return a.exec();
}
You should use QODBC instea of QOCI.
gogagubi's answer is good, but step 4 does not work for me because set INCLUDE and LIB does not work for mingw32-make.
It need to set INCPATH and LIBS in oci.pro or use:
qmake "INCPAH +=c:\app\user\product[version]\client_1\oci\include
LIBS +=-Lc:\app\user\product[version]\client_1\oci\lib\msvc" oci.pro
Add the following lines to the oci.pro:
INCPATH +=c:\app\user\product[version]\client_1\oci\include
LIBS+=-Lc:\app\user\product[version]\client_1\oci\lib\msvc
ciao tutto;
you can connect to oracle db with QODBC driver if it exist;(default in Qt windows is exist) Like below:
QSqlDatabase db=QSqlDatabase::addDatabase("QODBC");
db.setConnectOptions();
db.setDatabaseName("Driver={Microsoft ODBC for Oracle};Server=127.0.0.1:1521;Uid=ep;Pwd=605605");
if(!db.open())
exit(0);
QSqlQuery query(db);
query.exec("select * from t");
while(query.next())
QMessageBox::information(0,"",query.value(1).toString());
this is connected and allow to execurte query;
buona fortuna;
I am trying to decode a .wav file using QAudioDecoder class. Even though I had included the QtMultimedia module into my .pro file by adding
QT += multimedia I am receiving an error that service for the QAudioDecoder was not found. I am not able to see where to problem lies.
I am using Qt 5.1.0 with MingGW 4.8 32 bit on Windows 7.
Error message:
defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.audiodecode"
.pro file:
QT += core
QT += multimedia
QT -= gui
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
main file:
#include <QCoreApplication>
#include <QAudioDecoder>
#include <QAudioBuffer>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString pathToFile = "C:/Users/Mateusz/Documents/Szkola/Sound Processing/Lab1/artificial/easy/506Hz.wav";
QAudioDecoder decoder;
decoder.setSourceFilename(pathToFile);
decoder.start();
while(decoder.bufferAvailable()) {
QAudioBuffer buffer = decoder.read();
qDebug() << "Buffer size: " << buffer.byteCount();
}
return a.exec();
}
The Multimedia module uses plugins that are different on each platform (or compiler).
See http://qt-project.org/wiki/Qt_Multimedia_Backends
On Windows you have DirectShow and MediaFoundation (WMF).
Only the WMF plugin implements audio decoding features.
WMF plugin is only available with MSVC compiler.
See http://qt-project.org/doc/qt-5.1/qtmultimedia/platform-notes-windows.html
I had the same problem in Qt5.5 running under Linux.
The problem disappeared after upgrade to Qt5.5.1 using their MaintenanceTool.
I also struggled with this issue and finally got it to work by using the MS visual studio compiler in QT Creator, like Fernando Pelliccioni suggested.
Steps were:
-Use the Qt MaintenanceTool to add support for msvc2013
-Install Visual Studio 2013
-In Qt Creator go to Projects->Manage Kits and add msvc2013
-Build and run. Now QAudioDecoder works.
Well, I need to start working with OpenCV and as I'm used to working with QtCreator, I'm trying to make it all work together. I downloaded the latest OpenCV version, and compiled it with MinGW. Then, I created this little console project to try it out. Below is the .pro file:
QT += core
QT -= gui
TARGET = OpenCV_test4
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += C:\\Librerias\\opencv2.3.1\\release\\include
LIBS += -LC:\\Librerias\\opencv2.3.1\\release\\lib \
-lopencv_core231.dll \
-lopencv_highgui231.dll \
-lopencv_imgproc231.dll \
-lopencv_features2d231.dll \
-lopencv_calib3d231.dll
Here is the main.cpp file:
#include <QtCore/QCoreApplication>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
// read an image
cv::Mat image= cv::imread("img.jpg");
// create image window named "My Image"
cv::namedWindow("OpenCV Window");
// show the image on window
cv::imshow("OpenCV Window", image);
// wait key for 5000 ms
cv::waitKey(5000);
return a.exec();
}
(I have tried this code with and without the QCoreApplication lines)
The deal is: It links and builds, and when runs from QtCreator only a terminal window called C:\QtSDK\QtCreator\bin\qtcreator_process_stub.exe appears with the line "Press RETURN to close this window..."
But, if I run the .exe from the project folder, it runs perfectly!! Why is QtCreator unable to launch the application? I found this really strange, and I would appreciate any hint about this. It's really not THAT important, but it is kind of a pain to have to run the .exe manually every time I change something to check how it works.
Thanks for your time :)
Additional Info:
I have tried both debug and release versions, the problem is the same in both of them.
Debugging does not work, it never stops at any breakpoint.
I'm running on Windows 7 Proffesional x64
SOLVED, I don't really know what I did, it suddenly worked and keeps working, I wish I could tell you how I fixed it but I have no idea, such a weird thing :(
Check Projects -> Run Settings -> Run in terminal. It have to be enabled, but seems to be disabled.
I have met same problem with QtCreator and OpenCL under Linux. Simple test program works after start from terminal and it does not work after start from the QtCreator.
I found the cause was hardcoded LD_LIBRARY_PATH in the project's run environment settings. I had dropped it to empty string and this had fixed issue.
I had the same issue with the following environment: Raspbian, Qt, openCV and a gui application.
old-ufo recommendation worked for me:
- First, enable "Run in terminal", which failed
- Then, disable "Run in terminal", which allowed me to correctly debug my app.
I understand that this is not scientific.