On Qt Creator qmake project (on Windows), it seems I cannot Ctrl+Click when using a variable in the path of a source file.
The Ctrl+Click is very useful function to open the file.
Am I making a mistake at any point?
Related
I've been using qtcreator with an scons build, and for the life of me I can't get it to recognise the compile errors/warnings and put them in the build issues tab
The only difference I can see is that whereas the qmake output is something along the lines of
..\..\myfile.cpp:123:4 error xyz not declared in this scope
the scons output is along the lines of
project\subproject\myfile.cpp:123:4 error xyz not declared in this scope
as the scons build doesn't keep changing directory and builds from elsewhere.
Is there anything I can do to persuade QTCreator to look for the files in the right place, find them, and then add the appropriate line to the build issues tab,
Well, I have an answer (sort of).
I created a custom compiler which pointed to the studio compiler (not a clone) and changed my kit to use that.
Then I did a compile
Then I changed back to the microsoft visual studio compiler.
And now it works.
I have no idea why
Hello i'm a young develop on Qt. I want to know that can we convert project Qt (header, source, form, resource) to a file can run without Qt Creator? And how can we convert it to a file executable on window (.exe)?
The compiler is responsible for making an executable out of the source code. This has nothing to do with Qt.
When you start a program from the QtCreator an executable file is built by the compiler, then started. Have a look in your project folder to find that .exe file.
You dont have to do anything special. Each Qt project has a .pro file that is used for compiling. You need to use qmake on the command line with the .pro file as input. This will generate a makefile that you can then give to nmake.exe (if using Visual Studio compilers) or mingw-make (if you are uisng mingw compilers) to build. These steps will compile your source code into the .exe. Look through documentation of qmake to know more. Qt Creator also does the same steps and you can check out the buildlog in Qt Creator to see it working.
Yes, the exe file that you compile with Qt Creator or alternatively some other IDE or compiler is technically all you need to run the project from there on, except you need to have the linked Qt libraries somehow available to the executable. This is especially important if you plan to run it on a machine different from the one you developed it on. See the Qt documentation on Deploying Qt Applications for other details you may need to consider in that case.
Guys I've written app in qt and when trying to run it (double click on *.exe) I'm getting error that this application cannot start because qtnetwork4.dll isn't available. I've searched my drive and I found few files with this name (and copied one by one every time trying to run my app) but none of them seems to work. How can I solve it?
place into your *.exe - folder appropriate dll-s from %QT_PATH%\bin\
There is an app called Dependency Walker that will let you know what functions in qtnetwork4.dll are being used in your program. It can be found at the following:
http://www.dependencywalker.com/
All of the DLLs your program use will be from the same installation as the qmake.exe that is used to compile the program. If you are using Qt Creator you can see where the qmake.exe your using is located by going to:
tools->options->Qt4
Get the DLLs that are located at the path displayed here to make sure they will work with your program.
On windows, DLL are looked for in folder where executable lies, then using "PATH" environenment variable.
In your case, you want to put your dll along your executable, taking them from the sdk you're using to compile
The following page provides a lot of additional information on the subject (example, plugins, strategy for building installers)
To force using QtNetwork and linking it, you have to put
QT += network
in your poject file.
If you're sure you're not using it, you can use
QT -= network
I've added a QAction to my QToolBar in my MainWindow in Qt Designer (using the Qt Creator IDE) and given that Action an icon (done by "Choose File" and selecting my .png located in the same directory as my project and source code). The icon shows up fine in the toolbar in Qt Designer, but does not show when the project is running. I've had similar trouble when choosing the title bar icon on windows. I've never used graphics in Qt before, is there something special I need to do?
Screenshot:
I found myself doing all the right stuff, adding a qrc file and placing my icons there. When I run the program no deal.
Turn out I was forgetting to run qmake:
Right click your project's name and select "Run qmake". Or go to Build>Run qmake.
Everytime you change something in the .pro file you need to run qmake again. Creating a resource file implicitly adds argunments to the .pro file, so you need to do it.
Hope it helps other people out there.
Did you make a QRC file (that is, Qt's equivalent of a resource file?)
If not, that would explain what you're seeing. The icons will show up in the creator, but not in the final compiled executable. Have a look at this:
http://doc.qt.io/qt-5/resources.html
Also in case of shadow build don't forget to use windeployqt.exe on your application executable file. After that several folders will be added to your build directory. Particulary two important folders: iconengines and imageformats which contain several dlls needed to load and draw the icon.
Have you tried opening up the Project file. For example, my project file is named menu.pro and it contains the following:
TEMPLATE = app
QT = gui core
CONFIG += qt debug warn_on console
DESTDIR = bin
OBJECTS_DIR = build
MOC_DIR = build
UI_DIR = build
FORMS = ui/mainwindow.ui
HEADERS = src/mainwindowimpl.h
SOURCES = src/mainwindowimpl.cpp src/main.cpp
RESOURCES = Images.qrc
The last line (RESOURCES = Images.qrc) is what you need to put in your project file: of course, use the name that you used for your resources file, in my case, it is Images.qrc.
While adding icons use "Choose Resource" option instead of "Choose
File" option.
Right click your project's name and click "Run
qmake".
Also make sure you don't forget to include the qrc file in the code (e.g. in main(...)) with Q_INIT_RESOURCE(MyIconResource);
This can also lead to missing icons in the final exe.
I also faced such a problem. In my case, I closed qt creator and deleted the build folder (something like build-projectname.. ). Then restarted qt creator. Then magically my icon showed up on running application.
I often use this trick when qt doesn't behave well.
I'm using Qt Creator.
I'm using the signals and slots editor, and I want to see the code it generates.
How can I see the code?
Thanks!
Let's say you have in Qt Creator a form file called widget.ui.
Once you've compiled your project, you'll find in your project folder a filed called ui_widget.h.
If you open it, you'll see the code generated by the uic tool.
when you use qt creater, this one is going to create a file with the name of your project, in my case it is called "build-prueba-Desktop_Qt_5_7_0_GCC_64bit-Debug", then in that file you have to look for a file with the "ui_" prefix, into that, you have the code you need