[SOLVED] 3 questions
-
I'm developing a project for Windows. Using only widgets.
-
I've been developing my application with a 1920x1080 monitor in mind. Using it on machines with other resolutions is quite troublesome. What should be done to fit GUI for any monitor?
-
I go back and forth between different machines, so I use external hard drive to store my project. At the moment I have to copy my project to PCs each time I want to work on it. However, it would be much more convenient to work straight from external hard drive. But from there project fails to compile, qmake doesn't work. It only seems to work if my project is on the same hard drive as Qt Creator. Is there any way to make it so application can be compiled anywhere?
-
When I create a release build, I have to drag a lot of things with it, like different Qt dlls, platforms folder. So for an application that is around 150 kb I have to carry 50 Mb of other data. Is this normal practice? Seems to be weird.
-
-
Hi @Clint-Westwood,
-
Use layouts to handle different desktop resolutions (or even to allow your user to resize the window). These resize your widgets to fit. If you want to support radically different screens though (like a mobile phone or tablet screen), then you need to use different GUI designs.
-
Make sure you have the same version of Qt and Qt Creator, and the same compilation tools installed in both PCs. Then, delete the *.pro.user file each time you change PCs. That file contains machine-specific settings, so it will fail on a different machine.
-
Yes, that's normal. Qt is a very powerful framework, after all. The reason your executable is as small as 150 KB is because all the necessary code is already in the Qt DLLs. If you do a static build (that is, embed all the binary code within your executable instead of having separate DLLs), then your executable will grow to 50 MB or more. Note that the ICU DLLs contain mostly text data, so you can compress your app package quite significantly.
-
-
Thanks for the answers.
@JKSH said:
- Use [layouts]...
I haven't tried it on other resolutions yet, but setting layouts of various widgets and then setting main window layout to grid seemed to work. Now all widgets resize nicely according to main window. Thought it seems I get a bit less control over how ui looks that way. It seems that it tries to stretch everything to fill entire screen space, and in one place it gave a weird result: a Qframe containing three checkboxes stretched vertically a few times larger to fill empty space. Is there any way to gain more control over layouts?
@JKSH said:
- Make sure you have the same version of Qt and Qt Creator, and the same compilation tools installed in both PCs. Then, delete the *.pro.user file each time you change PCs. That file contains machine-specific settings, so it will fail on a different machine.
I'm aware of that and I always delete pro.user file before starting to work on application. Still not sure what is the problem.
@JKSH said:
- Yes, that's normal. Qt is a very powerful framework, after all. The reason your executable is as small as 150 KB is because all the necessary code is already in the Qt DLLs. If you do a static build (that is, embed all the binary code within your executable instead of having separate DLLs), then your executable will grow to 50 MB or more. Note that the ICU DLLs contain mostly text data, so you can compress your app package quite significantly.
Interesting. Just curious, would WinaPi or Winforms counterparts create smaller, same or larger size applications? Also regarding ICU DLLs, how could I compress my application? It won't run without them so I'm confused.
-
You're welcome :)
@Clint-Westwood said:
Thought it seems I get a bit less control over how ui looks that way. It seems that it tries to stretch everything to fill entire screen space, and in one place it gave a weird result: a Qframe containing three checkboxes stretched vertically a few times larger to fill empty space. Is there any way to gain more control over layouts?
Add stretches and spacings to your layout (See my previous link again, plus http://doc.qt.io/qt-5/qspaceritem.html )
Also, play with the widgets' size policies.
I'm aware of that and I always delete pro.user file before starting to work on application. Still not sure what is the problem.
In that case, please describe what you mean by "But from there project fails to compile, qmake doesn't work. It only seems to work if my project is on the same hard drive as Qt Creator". What error messages do you get? What behaviours do you see?
Interesting. Just curious, would WinaPi or Winforms counterparts create smaller, same or larger size applications?
I don't know, sorry. Note that for WinForms, your application would link to .NET DLLs instead of Qt DLLs. You might need to bundle the .NET installer with your app package, or ask your users to download .NET separately.
Note also that creating a GUI with WinAPI is a labour-intensive process.
Also regarding ICU DLLs, how could I compress my application? It won't run without them so I'm confused.
To clarify, I meant compress you files for distribution (a Zip file for users to download, for example). You'd need to decompress it to run your program.
-
@JKSH said:
Add stretches and spacings to your layout (See my previous link again, plus http://doc.qt.io/qt-5/qspaceritem.html ). Also, play with the widgets' size policies.
I see now, very convenient to use.
In that case, please describe what you mean by "But from there project fails to compile, qmake doesn't work. It only seems to work if my project is on the same hard drive as Qt Creator". What error messages do you get? What behaviours do you see?
I fixed it. QMake said that it couldn't find MyProject.pro, even though it was there. It even gave direct path in the error log. Turned out it was because some folders in the path were named using my native language. Changed all folders in the path to English and it compiled. That would be nice if in the next version this issue would be fixed.
Note also that creating a GUI with WinAPI is a labour-intensive process.
Yeah, that's the reason I've started looking for other tools to create GUI and came across Qt and I'm glad I've chosen it so far.
To clarify, I meant compress you files for distribution (a Zip file for users to download, for example). You'd need to decompress it to run your program.
Ah, alright.
I guess I mark it as solved, thanks again.
-
"3. When I create a release build, I have to drag a lot of things with it, like different Qt dlls, platforms folder. So for an application that is around 150 kb I have to carry 50 Mb of other data. Is this normal practice? Seems to be weird."
I noticed a big jump in the size of the dependencies from Qt4.x to Qt5.x. Projects in Qt4.x had dependencies between 10 and 15 mb usually.
If you download and compile Qt from source you can remove Webkit which will get rid of the dependencies on the ICU DLL's at least (one of those DLL's was 20+ MB if I remember correctly). After doing this I ended up with 15 and 20 mb of dependencies with the big three being Qt5Core.dll, Qt5Gui.dll, and Qt5Widgets.dll.
If you run the program and DLL's through a compressor / stripper this will help reduce the size. The one I used last time I downloaded from here: PortableApps.com AppCompactor . I am sure there are other utilities that will do the same thing.
I haven't look at all the options for reducing dependency size. I am okay with 15-20 MB in general.
-
Thanks, I'll have a look at it.