Why lupdate not include qml qstr string into .ts file? - qt

I have this .pro file :
TEMPLATE = subdirs
SUBDIRS += internal app
app.depends = internal
app.subdir = src/app
internal.subdir = src/internal
TRANSLATIONS = \
$$PWD/translations/croatian.ts \
$$PWD/translations/danish.ts \
$$PWD/translations/english.ts \
$$PWD/translations/french.ts \
$$PWD/translations/german.ts \
$$PWD/translations/italian.ts \
$$PWD/translations/norwegian.ts \
$$PWD/translations/portuguese.ts \
$$PWD/translations/romanian.ts \
$$PWD/translations/spanish.ts
internal.pro is this:
TEMPLATE = lib
TARGET = internal
CONFIG += c++1z
QT += core core-private gui quick serialport sql multimedia
DEFINES += CURRENT_PATH=\\\"$$PWD\\\"
CONFIG(release, debug|release) {
CONFIG += qtquickcompiler
QMAKE_CXXFLAGS += -O3
}
CONFIG(debug, debug|release) {
QMAKE_CXXFLAGS += -O0
QMAKE_CXXFLAGS -= -O1
QMAKE_CXXFLAGS -= -O2
QMAKE_CXXFLAGS -= -O3
QMAKE_CXXFLAGS += --debug
}
#MS_SKELETON_MODULES = core utils network
#include($$PWD/../external/ms-skeleton/ms-skeleton.pri)
include($$PWD/aggiornamento/aggiornamento.pri)
include($$PWD/allarmi/allarmi.pri)
include($$PWD/comunicazione/comunicazione.pri)
include($$PWD/core/core.pri)
include($$PWD/jsoncpp/jsoncpp.pri)
include($$PWD/mqtt/mqtt.pri)
include($$PWD/other/other.pri)
include($$PWD/parametri/parametri.pri)
include($$PWD/programs/programs.pri)
include($$PWD/serializer/serializer.pri)
unix: target.path = /opt/Tagliavini/lib
!isEmpty(target.path): INSTALLS += target
and app.pro is this :
TEMPLATE = app
TARGET = UserInterface
CONFIG += c++1z
QT += core gui quick sql multimedia
DEFINES += CURRENT_PATH=\\\"$$PWD\\\"
CONFIG(release, debug|release) {
CONFIG += qtquickcompiler
QMAKE_CXXFLAGS += -O3
}
CONFIG(debug, debug|release) {
QMAKE_CXXFLAGS += -O0
QMAKE_CXXFLAGS -= -O1
QMAKE_CXXFLAGS -= -O2
QMAKE_CXXFLAGS -= -O3
QMAKE_CXXFLAGS += --debug
}
LIBS += -L$$shadowed($$PWD)/../internal/ -linternal
INCLUDEPATH += \
$$PWD/../internal \
$$PWD/../external/ms-skeleton
SOURCES += $$PWD/main.cpp
RESOURCES += \
$$PWD/../../font/fonts.qrc \
$$PWD/../../images/images.qrc \
$$PWD/qml/qml.qrc \
$$PWD/../../sounds/sounds.qrc
unix: target.path = /opt/Tagliavini/bin
!isEmpty(target.path): INSTALLS += target
when i try to create file .ts with lupdate , the files are generated correctly , but the file .ts not cointeins the qstr strings that are into qml files. ( the file qml are into app.pro ), instead the string that i want to translate into .cpp files are all recognized correctly and put into .ts file.(these are into internal.pro) Where is the problem??

It seems that you are including your .qml files in .qrc resources but not in the project SOURCES itself. lupdate will not pick/parse your .qrc files to list .qml files.
So, you will have to add your .qml files to SOURCES either one-by-one or per directory.
lupdate_only{
SOURCES+=example.qml
SOURCES+=app/FancyControls/*.qml
}
This will duplicate your QML file entries in Qt Creator project pane tree which is not very desirable. So, you can comment out those lines in your .pro file and uncomment it before any lupdate. It's also mandatory to fence those imports in lupdate_only{} conditional statement. Make sure that there is no space between lupdate_only and the curly bracket. Actually, your C/C++ compiler would not expect a qml file to be compiled.

Related

Qt compile error : glib/galloca.h not found in glib-2.0/glib.h

I've the following error during Qt compiling phase :
In file included from ../test_ble2/main.cpp:12:
/opt/fsl-imx-xwayland/5.10-hardknott/sysroots/cortexa53-crypto-poky-linux/usr/include/glib-2.0/glib.h:30:10: fatal error: glib/galloca.h: No such file or directory
30 | #include <glib/galloca.h>
compilation terminated.
make: *** [Makefile:723: main.o] Error 1
looking for *.h and I found it on the board so the problem seems in *.pro file :
QT += quick
LIBS += -lbluetooth
LIBS += -lpython3
LIBS += -llibglib-2.0
SOURCES += \
main.cpp
RESOURCES += qml.qrc
QML_IMPORT_PATH =
QML_DESIGNER_IMPORT_PATH =
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
packagesExist(glib-2.0) {
CONFIG += link_pkgconfig
PKGCONFIG += glib-2.0
}
HEADERS += \
include/gattlib.h
unix:!macx: LIBS += -L$$PWD/lib/ -lgattlib
INCLUDEPATH += $$PWD/include
DEPENDPATH += $$PWD/include
but I' dont fix it, any suggestion?
The platform is yocto form imx8.
Any suggestion? Thanks in advance

Setting Up Gmock to QT (Windows)

I'm trying unit testing using QT Creator. I tried doing it with linux and it works really fine, but when I start doing it in Windows. I discover the setting up is way different than what I did to linux.
Right now in my Windows QT Creator, I already set up gtest to my project. Everything is working fine until I started to set up googlemock. Can someone tell me how to set up googlemock in QT Creator? (windows)
I added some gmock files in the sources in my .pro file just like what I did to the gtest files. Also, I already add some library like libgmock.a and libgmock_main.a.
Here's the image of the issue results Qt
INCLUDEPATH += "gtest/include/"
INCLUDEPATH += "gtest/"
INCLUDEPATH += "../../"
INCLUDEPATH += "gmock/include/gmock/"
INCLUDEPATH += "gmock/include/"
INCLUDEPATH += "gmock/"
INCLUDEPATH += "../../"
FORMS += \
../calculator.ui
HEADERS += \
../calculator.h \
../button.h
SOURCES += \
../calculator.cpp \
../button.cpp \
main.cpp \
gtest/src/gtest-typed-test.cc \
gtest/src/gtest-test-part.cc \
gtest/src/gtest-printers.cc \
gtest/src/gtest-port.cc \
gtest/src/gtest-filepath.cc \
gtest/src/gtest-death-test.cc \
gtest/src/gtest-all.cc \
gtest/src/gtest.cc \
gmock/src/gmock-spec-builders.cc \
gmock/src/gmock-matchers.cc \
gmock/src/gmock-cardinalities.cc \
gmock/src/gmock-all.cc \
gmock/src/gmock.cc \
gmock/src/gmock-internal-utils.cc
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../Gmock_lib/ -lgmock_main
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../Gmock_lib/ -lgmock_maind
else:unix: LIBS += -L$$PWD/../../../Gmock_lib/ -lgmock_main
INCLUDEPATH += $$PWD/../../../Gmock_lib
DEPENDPATH += $$PWD/../../../Gmock_lib
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../Gmock_lib/ -lgmock
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../Gmock_lib/ -lgmockd
else:unix: LIBS += -L$$PWD/../../../Gmock_lib/ -lgmock
INCLUDEPATH += $$PWD/../../../Gmock_lib
DEPENDPATH += $$PWD/../../../Gmock_lib
main.cpp
#include <gtest/gtest.h>
#include <QApplication>
#include "Calculator/calculator.h"
#include "Calculator/button.h"
#include "Calculator/calculator.h"
#include <gmock/gmock.h>
TEST (sumInMemory, clearMemoryF) {
calculator cal;
double x = cal.sumInMemory;
EXPECT_EQ( x , 0.0);
}
TEST (functionTest, Subtest1) {
calculator cal;
int x = cal.equalClicked();
EXPECT_NE( x , -1);
}
TEST (functionTest, Subtest2) {
calculator cal;
double x = cal.factorSoFar;
EXPECT_EQ( x , 0.0);
}
int main (int argc, char *argv[])
{
QApplication a(argc, argv);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
I experienced the same problem, I suggest you to download other version of gmock. In my case I use gmock 1.7.0. Some older version have some problems/issues. Just follow what the compiler says to you.
Fix bug one step at a time
My new .pro file
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += console c++14
INCLUDEPATH += "gmock/include/"
INCLUDEPATH += "gmock/"
INCLUDEPATH += "gtest/include/"
INCLUDEPATH += "gtest/src/"
INCLUDEPATH += "gtest/"
INCLUDEPATH += "../../"
FORMS += \
../calculator.ui
HEADERS += \
../calculator.h \
../button.h \
SOURCES += \
../calculator.cpp \
../button.cpp \
main.cpp \
gtest/src/gtest.cc \
gtest/src/gtest-all.cc \
gtest/src/gtest-death-test.cc \
gtest/src/gtest-filepath.cc \
gtest/src/gtest-port.cc \
gtest/src/gtest-printers.cc \
gtest/src/gtest-test-part.cc \
gtest/src/gtest-typed-test.cc
and the items inside my src file are
gmock-spec-builders.cc
gmock-matchers.cc
gmock-internal-utils.cc
gmock-cardinalities.cc
gmock-all.cc
gmock-main.cc
gmock.cc
note: I only use src and include for my gtest and gmock for my test file.
I hope this would help others

How do I include muparser library in my Qt project?

I made a muparser.pri which had the following content,
macx|win32|equals(build_muparser, "true")|!packagesExist(muparser){
message("Using bundled muparser")
MUPARSER_DIR = src/rel/muparser
DEPENDPATH += $$MUPARSER_DIR/include \
$$MUPARSER_DIR/src
INCLUDEPATH += $$MUPARSER_DIR/include
GEN_LIB_DIR = ../../generated/lib
LIBS += -L$$GEN_LIB_DIR -lmuparser
PRE_TARGETDEPS += $$GEN_LIB_DIR/libmuparser.a
}else{
message("Using external muparser")
CONFIG += link_pkgconfig
PKGCONFIG += muparser
}
I, then, added a
include(./muparser.pri)
in my application's make file.
This gave me an error
":-1: error: No rule to make target '../../generated/lib/libmuparser.a', needed by 'debug/Akaar1.exe'. Stop."
What did I do wrong? How else am I supposed to include this library in my project?
In your .pro file you can do:
LIBS += -L*path to the library* -l*library name: foo for libfoo.a*

Linking Qt + CUDA + external library

I've written a PRO file to generate a GUI for my CUDA application under linux (already compiled under windows now porting same components to ubuntu 1404).
I've first compiled a helper library "mylib.a" and linked that with my application "myapp.cu" and tested that it compiles and runs nicely without Qt in the picture (done via nsight eclipse).
For building with Qt I've generated the following PRO file:
#############################
# basic PRO file for qmake
##############################
# QT libs to use
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
##########################################
# QT basic files
##########################################
SOURCES+=main.cpp
SOURCES+=myGUI.cpp
HEADERS += myGUI.h
FORMS += myGUI.ui
# Project dir and outputs
PROJECT_DIR = $$system(pwd)
OBJECTS_DIR = $$PROJECT_DIR/Obj
DESTDIR = ../bin
##########################################
# CUDA source files
##########################################
CUDA_SOURCES += myApp.cu
CUDA_SOURCES += kernel1.cu
CUDA_SOURCES += kernel2.cu
##########################################
# CUDA related components
##########################################
CUDA_DIR = /usr/local/cuda
CUDA_ARCH = sm_35
NVCCFLAGS = --compiler-options -fno-strict-aliasing -use_fast_math --ptxas-options=-v
##########################################
# include paths
##########################################
# CUDA
INCLUDEPATH += $$CUDA_DIR/include
# Additional dependencies
INCLUDEPATH += /usr/include/
##########################################
# library directories
##########################################
QMAKE_LIBDIR += $$CUDA_DIR/lib64
QMAKE_LIBDIR += $$CUDA_DIR/samples/common/lib
##########################################
# LIBS
##########################################
LIBS += -lnvToolsExt
LIBS += -lopengl
#libcudart_static
#LIBS += -lcudart_static
LIBS += -lcuda
LIBS += -lcudart
LIBS += -lGL
# My library is added here
LIBS += -lmyLib
# join the includes in a line
CUDA_INC = $$join(INCLUDEPATH,' -I','-I',' ')
##########################################
# Extra compiler configuration for CUDA
##########################################
cuda.input = CUDA_SOURCES
cuda.output = ${OBJECTS_DIR}${QMAKE_FILE_BASE}.o
cuda.commands = $$CUDA_DIR/bin/nvcc $$CUDA_DEFINES -m64 -g -arch=$$CUDA_ARCH -c $$NVCCFLAGS $$CUDA_INC $$LIBS ${QMAKE_FILE_NAME} -c -o ${QMAKE_FILE_OUT}
cuda.dependency_type = TYPE_C
cuda.depend_command = $$CUDA_DIR/bin/nvcc $$CUDA_DEFINES -g -M $$CUDA_INC $$NVCCFLAGS ${QMAKE_FILE_NAME}
# Tell Qt that we want add more stuff to the Makefile
QMAKE_EXTRA_UNIX_COMPILERS += cuda
Try these in your .pro file. I used it to link to CUDA on Linux successfully :
# Define output directories
CONFIG(release, debug|release): CUDA_OBJECTS_DIR = release/cuda
else: CUDA_OBJECTS_DIR = debug/cuda
# This makes the .cu files appear in your project
OTHER_FILES += vectorAddition.cu
# CUDA settings <-- may change depending on your system
CUDA_SOURCES += vectorAddition.cu
unix{
CUDA_SDK = "/usr/local/cuda-5.5/" # Path to cuda SDK install
CUDA_DIR = "/usr/local/cuda-5.5/" # Path to cuda toolkit install
}
unix: SYSTEM_NAME = unix
SYSTEM_TYPE = 32 # '32' or '64', depending on your system
CUDA_ARCH = sm_30 # Type of CUDA architecture, for example 'compute_10', 'compute_11', 'sm_10'
NVCC_OPTIONS = --use_fast_math
# include paths
INCLUDEPATH += $$CUDA_DIR/include
#$$CUDA_SDK/common/inc/ \
#$$CUDA_SDK/../shared/inc/
# library directories
unix:{
QMAKE_LIBDIR += $$CUDA_DIR/lib
}
# Add the necessary libraries
unix:
{
CUDA_LIBS = -lcuda -lcudart
# The following makes sure all path names (which often include spaces) are put between quotation marks
CUDA_INC = $$join(INCLUDEPATH,'" -I"','-I"','"')
NVCC_LIBS = $$join(CUDA_LIBS,' -l','-l', '')
LIBS += $$CUDA_LIBS
}
# Configuration of the Cuda compiler
CONFIG(debug, debug|release) {
# Debug mode
cuda_d.input = CUDA_SOURCES
cuda_d.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.o
unix: cuda_d.commands = $$CUDA_DIR/bin/nvcc -D_DEBUG $$NVCC_OPTIONS $$CUDA_INC $$NVCC_LIBS --machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
cuda_d.dependency_type = TYPE_C
QMAKE_EXTRA_COMPILERS += cuda_d
}
else {
# Release mode
cuda.input = CUDA_SOURCES
cuda.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.o
unix: cuda.commands = $$CUDA_DIR/bin/nvcc $$NVCC_OPTIONS $$CUDA_INC $$NVCC_LIBS --machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
cuda.dependency_type = TYPE_C
QMAKE_EXTRA_COMPILERS += cuda
}

Compiling qt project with use of ffmpeg on x64 system

I have a qt project that uses some ffmpeg functionality, that i have compiled previously on windows (x86) and ubuntu. However, its x86 binaries do not work correctly on x64 windows machine. I have tried compiling it but have run into a strange problem.
All ffmpeg functions i use are listed as unresolved exgternals; and the most pecicular thing is, their names all ahve a leading underscore attached to them (so, avformat_close_input -> _avformat_close_input etc). To be sure, i have downloaded latest ffmpeg libraries for x64 machines and run them through a dependency walker - no leading underscores anywhere.
How to fix this problem?
Here is my .pro file:
#-------------------------------------------------
#
# Project created by QtCreator 2013-05-17T10:55:01
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = LPR_Demo
TEMPLATE = app
# The application version
VERSION = 1.0
# Define the preprocessor macro to get the application version in our application.
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
SOURCES += main.cpp\
mainwindow.cpp \
imgProcessor.cpp \
qpicturelabel.cpp \
aboutdialog.cpp \
state.cpp \
qt_videoreader.cpp \
roidialog.cpp \
recognitionresult.cpp \
ffmpeg_reader.cpp \
label_videoplayer.cpp
HEADERS += mainwindow.h \
imgProcessor.h \
qpicturelabel.h \
aboutdialog.h \
state.h \
qt_videoreader.h \
roidialog.h \
recognitionresult.h \
global.h \
ffmpeg_reader.h \
label_videoplayer.h
FORMS += mainwindow.ui \
aboutdialog.ui \
roidialog.ui
LPRDIR = $$PWD/LPR
win32: LIBS += -L$$LPRDIR/bin/ -lliblpr
unix:LIBS += -L$$LPRDIR/bin -lLPR
INCLUDEPATH += $$LPRDIR/include
DEPENDPATH += $$LPRDIR/include
INCLUDEPATH += $$PWD/
DEPENDPATH += $$PWD/
#OTHER_FILES += \
# ffmpeg.pri
include(ffmpeg.pri)
#LIBS += -lavformat -lavcodec -lavutil -lswscale
RESOURCES += \
lpr_Res.qrc
win32 {
dlls_to_move.path += $$OUT_PWD/bin
dlls_to_move.files += $$LPRDIR/bin/liblpr.dll
QTDIR=C:/Qt/4.8.4/
CONFIG (debug, debug|release) {
dlls_to_move.files += $$QTDIR/bin/QtCored4.dll \
$$QTDIR/bin/QtGuid4.dll
}
CONFIG (release, debug|release) {
dlls_to_move.files += $$QTDIR/bin/QtCore4.dll \
$$QTDIR/bin/QtGui4.dll
}
img_format.path += $$OUT_PWD/bin/imageformats
CONFIG (debug, debug|release) {
img_format.files += $$QTDIR/plugins/imageformats/qgifd4.dll \
$$QTDIR/plugins/imageformats/qicod4.dll \
$$QTDIR/plugins/imageformats/qjpegd4.dll \
$$QTDIR/plugins/imageformats/qmngd4.dll \
$$QTDIR/plugins/imageformats/qsvgd4.dll \
$$QTDIR/plugins/imageformats/qtgad4.dll \
$$QTDIR/plugins/imageformats/qtiffd4.dll
}
CONFIG (release, debug|release) {
img_format.files += $$QTDIR/plugins/imageformats/qgif4.dll \
$$QTDIR/plugins/imageformats/qico4.dll \
$$QTDIR/plugins/imageformats/qjpeg4.dll \
$$QTDIR/plugins/imageformats/qmng4.dll \
$$QTDIR/plugins/imageformats/qsvg4.dll \
$$QTDIR/plugins/imageformats/qtga4.dll \
$$QTDIR/plugins/imageformats/qtiff4.dll
}
ffmpeg_dll.path += $$OUT_PWD/bin
ffmpeg_dll.files += $$FFMPEG_LIBRARY_PATH/avutil-*.dll \
$$FFMPEG_LIBRARY_PATH/avcodec-*.dll \
$$FFMPEG_LIBRARY_PATH/avformat-*.dll \
$$FFMPEG_LIBRARY_PATH/swscale-*.dll
main_exe.path += $$OUT_PWD/bin
CONFIG (debug, debug|release) {
main_exe.files += $$OUT_PWD/debug/LPR_Demo.exe
}
CONFIG (release, debug|release) {
main_exe.files += $$OUT_PWD/release/LPR_Demo.exe
}
INSTALLS += dlls_to_move img_format ffmpeg_dll main_exe
}
unix {
CONFIG (release, debug|release) {
QMAKE_PRE_LINK += rm LPR_Demo_cmpr LPR_Demo$$escape_expand(\n\t)
QMAKE_POST_LINK += upx -9 -oLPR_Demo_cmpr LPR_Demo$$escape_expand(\n\t)
QMAKE_POST_LINK += cp -v -u LPR_Demo_cmpr $$OUT_PWD/../artifacts/examples/qt_demo/bin/unix
}
}
and here is pri file for ffmpeg:
# Include the configuration file below in the QT .pro file, and modify the path accordingly.
# ##############################################################################
# ##############################################################################
# FFMPEG: START OF CONFIGURATION BELOW ->
# Copy these lines into your own project
# Make sure to set the path variables for:
# 1) ffmpeg_reader,
# 2) FFMPEG include path (i.e. where the directories libavcodec, libavutil, etc. lie),
# 3) the binary FFMPEG libraries (that must be compiled separately).
# Under Linux path 2 and 3 may not need to be set as these are usually in the standard include and lib path.
# Under Windows, path 2 and 3 must be set to the location where you placed the FFMPEG includes and compiled binaries
# Note that the FFMPEG dynamic librairies (i.e. the .dll files) must be in the PATH
# ##############################################################################
# ##############################################################################
# ##############################################################################
# Modify here: set FFMPEG_LIBRARY_PATH and FFMPEG_INCLUDE_PATH
# ##############################################################################
# Set FFMPEG_LIBRARY_PATH to point to the directory containing the FFmpeg import libraries (if needed - typically for Windows), i.e. the dll.a files
win32:FFMPEG_LIBRARY_PATH = $$PWD/ffmpeg/lib
unix: FFMPEG_LIBRARY_PATH = /usr/local/lib
# Set FFMPEG_INCLUDE_PATH to point to the directory containing the FFMPEG includes (if needed - typically for Windows)
win32:FFMPEG_INCLUDE_PATH = $$PWD/ffmpeg/include
unix:FFMPEG_INCLUDE_PATH = /usr/local/include
# ##############################################################################
# Do not modify: FFMPEG default settings
# ##############################################################################
# Set list of required FFmpeg libraries
#unix:LIBS += -L$$FFMPEG_LIBRARY_PATH
unix:LIBS += -lavformat -lavcodec -lavutil -lswscale
# Add the path
win32:LIBS += -L$$FFMPEG_LIBRARY_PATH
win32:LIBS += -lavformat -lavcodec -lavutil -lswscale
INCLUDEPATH += $$FFMPEG_INCLUDE_PATH
# Requied for some C99 defines
DEFINES += __STDC_CONSTANT_MACROS
# ##############################################################################
# FFMPEG: END OF CONFIGURATION
# ##############################################################################

Resources