QGraphicsItem does not show - qt

I wrote a simple application that displays QGraphicsPixmapItems in a QGraphicsScene. The application should be portable without installing Qt on the operating system. I managed to copy only the needed dll files to start the application. Everything works except the QGraphicsItems are not displayed at all, although they are in the scene (wrote a logfile that counts the items).
I figured out that the items are shown correctly, if I copy my "portable" exe file into Qt\Qt5.2.1\5.2.1\mingw48_32\bin folder.
The opposite does not work: If I copy all of the bin-folder to my portable application folder, it does not work. How can I use a QGraphicsItem in a portable Qt application?

you might miss a plugin for the images you want to display.
make sure your application directory looks like this:
<root>
- <executable>
- <imageformats>
- <used image libraries>

I found the reason: I needed to add the folder Qt\Qt5.2.1\5.2.1\mingw48_32\plugins\imageformats to my "portable-app"-folder. In particular, the needed dll was qjpeg.dll.

Related

QtCreator Build doesn't update UI changes in design form

My Qt project uses shadow build.
When I change in MainWindow form ( .ui file), I build the project but my program doesn't update GUI.
If I rebuild all, GUI will be updated. But rebuild is very very slow.
I try creating a new project (an empty QMainWindow with some labels), I modify some texts. I build and GUI is updated.
How can I use shadow build correctly, without a rebuild of all my project?
The same issue occurs if the *.ui file name is changed.
For example, Changing yourUi.ui to myUi.ui.
If that is the scenario, then the ui_*.h should also be changed, that is, yourUi.ui to ui_myUi.h.
close Qt creator, go to your project directory and delete the .pro.user file, open the project again and this time Qt creator will ask you to configure your project by choosing the kit you use to build your project. Select the appropriate kit and press the "configure project" button. Apply your shadow build. I hope it will work.
Have you tried to just run qmake (Build -> Run qmake) ?
Edit
As suggested by a comment, I copied the comment to preserve it.
It seems that QtCreator correctly rebuild the .h file of the ui in the shadow build directory, and then include the ones in the source directory, which is not regenerated. I don't know if this is a bug or an intended behaviour, but a quick workaround can be to build the project in the shadow build directory, copy the generated .h files back in the source directory and rebuild again. This work with my simple project, don't know if can be workable also for bigger and more complex project. Or do not use shadow builds

OpenGL Widget works in creator but black when launched from .exe

I have been working on a Qt OpenGL project for a bit now for some school work. I had to re-build Qt 5.0.1 for my windows machine so I could use OpenGL proper. At the end of this project I need to turn over the files and any executables, so I figured I could take the release .exe and stick it in a .zip for use.
I followed instructions online of making sure I place any needed .dll's into the .exe's dir. For my project there are 10:
icudt49, icuin49, icuuc49, libEGL, libGLESv2, Qt5Core, Qt5Gui, Qt5OpenGL and Qt5Widgets
I took these files all from:
C:\Qt\Qt5.0.1\5.0.1\msvc2010\bin
on my system.
Issue is the .exe will run and I get the UI and all. But the OpenGL scene is just black. I can still click objects in the scene, evidently zoom in and out and all that. I assume thats just the Qt translating the commands still. But nothing is visible. I'm unsure what the problem can be because it all works fine when launched from the creator.
EDIT: So, with all the dlls in the release folder, running the project from within creator will also have a black screen, when I remove them, it runs well. So perhaps one of the dll's is just wrong?
Also:
I looked online about publishing with Qt Creator and found not too much aid, said I should start from completely rebuilding Qt Creator staticly, but I'm sure the guide I had followed did this, however I still can't publish from the build menu, so I stuck with the above method.
I suggest, that you open every of the DDLs in your Zip file with Dependency Walker (http://www.dependencywalker.com/). It should display information about dependencies from one of your QtXXX.dll files to other files. If one of the dependencies is missing, you know where to look next. You can also try to open your executable with Dependency Walker. I haven't used the program for a long time so I don't remember if opening an executable is the only way it works. Anyway, here are the reasons why you might want to use the tool: http://www.dependencywalker.com/help/html/overview_1.htm
This question might also be helpful:
At least one module has an unresolved import due to a missing export function in an implicitly dependent module
Good luck!
So the ultimate issue was the use of the correct DLLs. Using something like DependenyWalker can help you to note which DLLs may be missing, however it did nothing in my case.
I had installed Qt once, and also rebuilt, uninstalled and re-installed it. However all the libraries it was calling from as no longer in C:\Qt\Qt5.0.1\5.0.1\msvc2010\bin as expected, it was calling from the github repository where I built it C:\Users\User\Documents\GitHub\qt5. Once this is sorted out, it still required a framework folder and then it works as expected.
1) Copy the correct DLL files to the release folder of the build.
2) Create a folder in the same dir as the .exe named "platforms". (Note: elsewhere has said create plugins>platforms, but this will not work with newer Qt versions)
3) From the same source you got the other DLLs, copy qwindows.dll to the platforms folder you created.
4) Run the executable and enjoy.
As long as the system you're running on is capable of your OpenGL structure, it should be fine.

QWebview examples: only runs in specific directory

I'm trying to create a Qt app with a webview. I started out with a very simple UI with nothing more than a QWebview. When trying ui->webview->SetUrl("http://google.com"); the application crashes on something with openssl.
Auto configuration failed
3348:error:0200107B:system library:fopen:Unknown error:.\crypto\bio\bss_file.c:169:fopen('c:cygwinhomeAdministrateurbuildslavefull-windows_xp_32buildgpac_extra_libs/c:cygwinhomeAdministrateurbuildslavefull-windows_xp_32buildgpac_extra_libs/ssl/openssl.cnf','rb')
3348:error:2006D002:BIO routines:BIO_new_file:system lib:.\crypto\bio\bss_file.c:174:
3348:error:0E078002:configuration file routines:DEF_LOAD:system lib:.\crypto\conf\conf_def.c:199:
I continues trying the examples. Domtraversal is one of the easier applications so i tried to build and run this. It works.
Changed the url to "https://gmail.com" which also works (so no ssl issues there).
When i run the debug or release .exe it works normally (qt's bin path is in my path var so there are no dll problems), but when i move the executable to say, my Desktop it does not run.
I've tried several different things:
when i have any tree with the same amount of folders up to "build-domtraversal-Desktop_Qt_5_0_2_MSVC2010_32bit-Debug" as the folder it is build in continues by release with the executable in it (so: c:/test/test/test/test/test/test/build-domtraversal-Desktop_Qt_5_0_2_MSVC2010_32bit-Debug/release/app.exe) it works
When i add folders inside the release folder (...-Debug/release/test/test/app.exe) it works
When i change the name of either "build-domtraversal-Desktop_Qt_5_0_2_MSVC2010_32bit-*" or release folders it does not work (exept for the end of the build folder name)
When i change the name of the app itself it works.
When i change the folder structure to D:/* it does not work
When i turn off shadow build it does not work anymore in debug mode either. Unless i move the output .exe back into a folder structure where it did work.
There must be a path somewhere in the .pro.user or somewhere else i haven't thought about. Can anyone point me in the right direction? Cause right now I'm starting to believe in magic...

C++ Qt - QPixmap does not load with Qt Creator, but load when run via terminal

I am coding a GUI using Qt. When I run the application using QtCreator, my images do not load, and I receive the following error:
QPixmap::scaled: Pixmap is a null pixmap
Yet, when I run the application via command line, everything displays perfectly.
Why so? And how can I get QtCreator to load my images properly?
NB: Those images are barely 20ko each, so what I read about images being too big can't apply.
EDIT: A typical filename is 'Images/Cards/Base/card01.jpg', where Images is a subdirectory of my project directory (the code being at the root)
If you are working with images that should be bundled with the application, such as icons, then you should try and make use of the Qt Resource system.
This allows you to build the resources into the actual project and reference them in a filesystem independent syntax. i.e.: :/icons/myIcon.png
Most likely you have a difference between the relative location of the file in Qt Creator vs the command line.

QPixmap image loading problem

Basically I am trying to load the image as a texture using QPixmap:
texture[T_WALL] = bindTexture(QPixmap(":/images/wall.png"), GL_TEXTURE_2D);
The code works on my development machine, but not in the vm / other pcs without QT. Initially I was using jpegs and just assumed that I messed up the plugins, but as I understand, no plugins are needed for png files so I have no idea where the problem is.
Results are the same when loading local files and using Qt resources.
I am deploying libgcc_s_dw2-1.ddl, mingwm10.dll, QtCore4.dll, QtGui4.dll, QtOpenGL4.dll. Do I need anything else?
Try adding an imageformats directory to your application directory and put qmng4.dll there. See my answer to the question Qt dll deployment on windows
If it still does not work, get the Sysinternals suite which contains dgbview.exe that allows you to watch qDebug messages (even for release builds).

Resources