how open in eclipse ".pro File Editor" - c++

i'm need in eclipse the qt and openCV library. i'm found the tutorial http://www.welding.iat.uni-bremen.de/cms/index.php?view=article&catid=14%3Aimage-processing&id=14%3Aa-tutorial-on-integrating-eclipse-qt-and-opencv&format=pdf&option=com_content&Itemid=24 where writen last step "
We make sure that the Advance Mode is selected, we create a New Variable (1) and we give the name LIBS to this variable (2)
selecting the Append as Assignment Operator.
We have to add the following content to the variable(2), -L/usr/local/lib -lcxcore -lcv -lhighgui -lcvaux".
how my open last window so as double clicking don't open. Opens file where code
TEMPLATE = app
TARGET = ex1
QT += core gui
HEADERS += ex1.h
SOURCES += main.cpp \
ex1.cpp
FORMS += ex1.ui
RESOURCES +=
how my run it task?
sorry bad english.

If I understand correctly: Right click on .pro file and go to 'Qt Project Editor', if it is not there then you can use the text editor option (or something is wrong with your Eclipse Qt installation).

Related

Using preload-file compiler option for emscripten compiler to load local file in Qt

I am building an Qt Application using WebAssembly. I want to open a local file and read it frin my code which isn't exacty easy with WebAssembly. I tried using the preload-file option (reference) in my .pro file:
CONFIG += preload-file /path/to/file/Settings.ini
However, when compiling my application with WebAssembly, It fails showing my the following error:
Application exit (RuntimeError: Aborted(native code called abort()))
I am currently using Qt 6 with the fitting Emscripten version. My code works when compiling with GCC. Of course, emscripten compiles when removing the file handling stuff from my code. Using a file dialog isn't a suitable option.
I noticed you are using CONFIG += but the emscripten reference says it is a linker flag. Try using instead QMAKE_LFLAGS += --preload-file /path/to/file/Settings.ini.
Personally, I have not tested preload-file option but two other options have been working for me:
The similar embed-file functionality. In the .pro file add QMAKE_LFLAGS += --embed-file ../../cdpcore/Templates/Models#Models to make the folder specified to be available in [working directory]/Models.
Use the Qt Resource system to embed files. Basically add a .qrc file to your project that lists resources to embed into the binary and then into the .pro file add RESOURCES += resources.qrc.

'fbxsdk.h' file not found in my Mac Qt project,How add FBX SDK in my Mac Qt project?

I developed a Qt project on Mac which transplanted from Windows Qt,everything is working fine in Windows Qt,but in Mac Qt show many errors, one of them is :
'fbxsdk.h' file not found
it seem to say I have not add FBX SDK to my Mac Qt project. so I add it according official website: https://help.autodesk.com/view/FBX/2017/ENU/?guid=__files_GUID_724E9FAD_AFA0_4348_BDAA_6CF2FDF2FF55_htm .
and study add FBX SDK in Windows Qt project in this website : https://forums.autodesk.com/t5/fbx-forum/including-sdk-to-qt-creator/td-p/8184654 .
so I edit my .pro, the content is here :
LIBS += /Applications/Autodesk/FBX\ SDK/2019.2/lib/clang/debug/libfbxsdk.a
LIBS += /Applications/Autodesk/FBX\ SDK/2019.2/lib/clang/debug/libfbxsdk.dylib
INCLUDEPATH += /Applications/Autodesk/FBX\ SDK/2019.2/include
DEPENDPATH += /Applications/Autodesk/FBX\ SDK/2019.2/lib/clang
it still show error : 'fbxsdk.h' file not found, how should I add FBX\ SDK in my Mac Qt project,thanks a lot!
I had fixed it:
I used the 'otool -L' with execute file of my App in the terminal,it shows the libfbxsdk.dylib load path is '#executable_path/libfbxsdk.dylib',in my '#executable_path/' there no libfbxsdk.dylib in it,so it shows error,so I think why the loadpath of 'libfbxsdk.dylib' is '#executable_path/libfbxsdk.dylib',can I change it?
the answer is 'YES'
how I change the 'install name' of libfbxsdk.dylib you can find in this pic :
of course,you can use a another popular way,change the loadpath of 'libfbxsdk.dylib' use the 'install_name_tool -change' in the terminal,here is my example to change it in pic:
now you use the 'otool -L' with execute file in the terminal again,the loadpath of libfbxsdk.dylib change to '/Applications/Autodesk/FBXSDK/2019.2/lib/clang/debug/libfbxsdk.dylib' from '#executable_path/libfbxsdk.dylib'

Using External Binary Resource

I'm on a project that used to have Compiled-in Resources.
Now, the user can choose the theme that he wants to work on. No problems until there, in a little research I started to use the External Binary Resource approach.
My resources were build successfully and the QResource::registerResource("/path/to/myresource.rcc"); returns true.
It is not working properly though. Apparently the compiled-in resource is still there, in the executable. I can't see the different icons stored in my external binary resource.
How do I remove this compiled-in resource? Do I need to do that to work properly?
Assuming you are using a .pro file for your project, you need to remove the resource file from the RESOURCES list. If you still want it to be listed in your project, you can use OTHER_FILES.
Before:
RESOURCES += file1.qrc file2.qrc
After:
RESOURCES += file2.qrc
OTHER_FILES += file1.qrc
If you want to go a step further you can automate the build of qrc files:
RCC_BINARY_SOURCES += file1.qrc
asset_builder.commands = $$[QT_HOST_BINS]/rcc -binary ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT} -no-compress
asset_builder.depend_command = $$[QT_HOST_BINS]/rcc -list $$QMAKE_RESOURCE_FLAGS ${QMAKE_FILE_IN}
asset_builder.input = RCC_BINARY_SOURCES
asset_builder.output = $$OUT_PWD/$$DESTDIR/${QMAKE_FILE_IN_BASE}.qrb
asset_builder.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += asset_builder
OTHER_FILES += $$RCC_BINARY_SOURCES
You have to change the way the resources are compiled. By default, every resource file (resources.qrc, for example) included in a Qt project is compiled to C++ code (the qrc_resources.cpp you've probably seen after compiling the project). That makes the resource is compiled and linked with your executable (or library). The Qt for Visual Studio plugin does exactly that: adds a custom build step to every QRC file. Open the properties of the QRC file to take a look (right-click on the QRC file, then Properties):
Command line: "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp
Outputs: .\GeneratedFiles\qrc_%(Filename).cpp
%(Filename) is, as you can figure out, the extension-less name of the file
To avoid this behaviour just remove the QRC file from the project. Of course, the problem is that you'll have to manually build the .rcc file. You can do it using a script as part of your makefile.
On the other hand, if you're using Visual Studio, you can change the command used to compile it, adding the -binary option to the rcc tool so it compiles to an external file. In this way it will be included in your usual compilation workflow:
Command line: "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" "%(FullPath)" -binary -o "%(Outputs)"
Outputs: $(OutDir)\%(Filename).rcc - it is different from screenshot because I took it from an existing project, use the one in the text to place the RCC file in the same dir of your executable.
Important note: be sure you change the build tool for all the configurations.
If you use a makefile or Qt Creator instead, you can use this as a base to create the needed script.
Hope this can help you.

Why doesn't my Qt application present a GUI when executed?

I have been given a C++/C code with a .pro file to compile in Qt (it is a large, messy code, so I would like to use Qt and the .pro file provided).
The code is intended to generate a GUI. I can compile it in Qt without any errors (on both Mac OS X 10.7.5 and Mac OS X 10.8), and I see the executable. However, when I click on it, nothing happens. When I run it the usual way via the command line nothing happens. Here are the run commands I'm trying:
./calc.app/Contents/MacOS/calc
exec ./calc.app/Contents/MacOS/calc (this one results in the output: [Process completed]).
In the .pro file (below), I do not see anything that seems to indicate I want a GUI. However, I read at the Qt help site that the GUI module does not need to be specified in the .pro file because it is included automatically. Perhaps I am misunderstanding something?
Are the any issues with my .pro file?
TEMPLATE = app
LANGUAGE = C++
TARGET = calc
VERSION = 3.1.0
CONFIG -= qt
CONFIG += warn_on
CONFIG += debug
#CONFIG += windows
CONFIG += console
DEFINES += IPMGEMPLUGIN
DEFINES += NOPARTICLEARRAY
!win32 {
DEFINES += __unix
}
GMS_CPP = ../GMS
GMS_H = $$GMS_CPP
DEPENDPATH +=
DEPENDPATH += .
DEPENDPATH += $$GMS_H
INCLUDEPATH +=
INCLUDEPATH += .
INCLUDEPATH += $$GMS_H
QMAKE_LFLAGS +=
OBJECTS_DIR = obj
SOURCES += main.cpp
include($$GMS_CPP/gms.pri)
I don't know anything about Qt, and of course none of us know anything about the specific application you're compiling - so the assistance I can give you may be woefully inaccurate.
However, this sticks out like a sore thumb:
#CONFIG += windows
CONFIG += console
A quick Google search indicates that Qt does indeed support console applications - that is, applications which do not create a GUI, but instead act as console / terminal / command-line tools. This appears to be the case with the one you're working with. Presuming the application even works, it likely expects input to be passed to it on the command line, and will produce output of some sort in response - but with this configuration, it will not create a GUI.
I recommend contacting the person who gave you this application for further support.
CONFIG -= qt basically means "The target is [not] a Qt application/library and [does not require] the Qt library and header files." You should delete that line. Source: http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#config
Also, it couldn't hurt to add QT += core gui. This is normally done for you automatically, but since you're having project file problems it couldn't hurt... Also, make sure your main.cpp's main method ends in return a.exec();, and that a is a QApplication instance (Qt 4.x) or a QGUIApplication instance (Qt 5.x). main.cpp should be a short function that creates the main widget or window, shows it, then starts the event loop.
If your project still doesn't work properly, I would highly recommend that you ditch the project file. In other words, I would download the OS X package for the Qt SDK, create a new project, then import your files into the new project. After that, I would pluck only the necessary lines from your old .pro file and put them in the new one until it works (specifically, I noticed you have some custom DEFINES += ...). However, all of this advice assumes the fault lies in the project file, not your code. ;-)

How to link opencv in QtCreator and use Qt library

This question must be duplicate many times, but it just doesn't work and sometimes it still remains unanswered. Sources of information are mainly these
http://www.laganiere.name/opencvCookbook/chap1s1_2.shtml
http://www.youtube.com/watch?v=dgcXYQijV6c
This is the summation of what I think one should/can do. (And now it works for me.) Hopefully I mentioned everything from the very beginning, the aim is to write a very clear tutorial.
Installation of OpenCV for QtCreator
I have already MS Visual Studio 2010 Professional installed. (I have a free licence as a student) - I think this is not necessary, just a mention
Download: Qt 5.0.1 for Windows 32-bit (MinGW 4.7, 823 MB)
2.1 Install: Warning, everything that Qt uses (e.g. OpenCV) must be in directories that don't contain white-spaces in their names. - i.e. "Program Files" is wrong. (But I don't want different program files to accumulate directly on C, so I've only made a folder "Programs" in which everything important is installed)
Download: cmake-2.8.10.2-win32-x86.exe - Install for all users (this can be in Program Files)
Download: OpenCV-2.4.0.exe, extract to: C:\Programs\opencv24 - it'll create a dir "opencv"; add another folder "opencv_bin". Now it looks like this:
C:\Programs\opencv24\opencv*
C:\Programs\opencv24\opencv_bin
Set PATH environment variable, so that there be a link to MinGW compiler. e.g. C:\Programs\Qt\Qt5.0.1\Tools\MinGW\bin;
Start cmake-gui.exe
6.1 source code: set the default dir for OpenCV; C:\Programs\opencv24\opencv
6.2 binaries: set the opencv_bin dir; C:\Programs\copencv24\opencv_bin
6.3 click configure:
Choose MinGW Makefiles and Specify native compilers, click next
Field C is for gcc.exe; C:/Programs/Qt/Qt5.0.1/Tools/MinGW/bin/gcc.exe
Field C++ is for g++.exe; C:/Programs/Qt/Qt5.0.1/Tools/MinGW/bin/g++.exe
Field fortran can be empty, click finish
6.4 Many red lines will appear To the search field enter one by one: WITH_QT, WITH_TBB, WITH_IPP, WITH_CUDA, CMAKE_BUILD_TYPE
WITH_QT - must be selected.
WITH_TBB, WITH_IPP, WITH_CUDA - must be unselected
CMAKE_BUILD_TYPE - click and enter a text "Debug" (without quotes).
Clear the text from the Search field.
6.5 click configure and keep clicking configure until all red lines are gone, then click generate and close cmake-gui.exe
Go to the terminal (~command prompt), cd to the directory where are the builds (opencv_bin) and type mingw32-make
When the process ends after a long time, type mingw32-make install
Add into Path variable the path to the QtCreator/bin C:\Programs\Qt\Qt5.0.1\Tools\QtCreator\bin
Now I have created a new console app in QtCreator.
//cvHello.pro
QT += core
QT -= gui
TARGET = cvHello
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
INCLUDEPATH += C:/Programs/opencv24/opencv_bin2/install/include
LIBS += "C:/Programs/opencv24/opencv_bin2/bin/*.dll"
SOURCES += main.cpp
OTHER_FILES += \
img.JPG
And the main file:
//main.cpp
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"
using namespace std;
int main()
{
cout << "Hello World!" << endl;
cv::Mat mat;
mat = cv::imread("img.JPG");
cvNamedWindow("hello");
cv::imshow("hello",mat);
cvWaitKey(0);
return 0;
}
Finally I am starting to be happy. When adjusting this question I had to try all the ways how to define LIBS. Listing them manually helped, at first I wrote them somehow wrong.
This is how it works finally:
LIBS += -LC:\\Programs\\opencv24\\opencv_bin2\\bin \
libopencv_core240d \
libopencv_highgui240d \
libopencv_imgproc240d \
libopencv_features2d240d \
libopencv_calib3d240d \
The originally accepted answer did not work for me, I am running MSVC2013 Professional and QT5.9. I found SIMPLE and SUREFIRE CROSS-PLATFORM solution that should help anyone who is trying to link an external library (like openCV) with QT.
The steps listed below are found in the Qt5 documentation: http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html under the "To Add Library" section.
Right click on the project file located in the 'project pane' on the left side of the creator... and select "Add Library..."
Follow the instructions of the wizard
Let me add some specificity from here:
Select "External Library"
For the "Library File" navigate to your opencv_worldXXX.lib file (or opencv_worldXXXd.lib file, you will notice that by specifying only one or the other the wizard has a checkbox which includes the other automatically) [ex. ...\opencv\build\x64\vc12\lib\opncv_world310.lib]
For the "Include Folder" navigate to the "include" folder within the build. [ex. ...\opencv\build\include]
Select your operating system, dynamic/static library (whichever is appropriate)
Hit NEXT, CLEAN UP, and RUN!