Unsolved What does QT -= gui do?
-
I understand what +-= does in C
I do not get why adding QT widget class to project came up with this
QT -= gui
and I had to add this manually
QT += widgets
-
@AnneRanch
QT += X
adds the submodule X, andQT -= X
does the opposite. That is not an arithmetic addition or subtraction but an addition or removal of modules.Adding (or removing) submodules implies that the resulting makefile (the product of the .pro) will link the binaries of the submodule. For example in your case when using widget you need to have accessible all the widget classes so QT + = widgets does that magic, for example it is also responsible for linking the other dependent submodules, for example widgets depends on core and gui, like this to do
QT -= gui
QT += widgets
is the same asQT += widgets
since gui was removed but then added. -
@eyllanesc I am new to Qt and feel that I've to learn a lot. I am learning through various online resources and youtube Tutorials and often get stuck in many positions. Can you please clarify what 'binaries of the modules' mean that you've written in your answer?
Thanks in advance!
-
@AnneRanch Do you understand that they are C++ libraries? Do you understand what is .so, .dll or .dylib? Do you understand what the compilation process involves in C++? If you do not know then investigate so that later you can explain
-
@AnneRanch said in What does QT -= gui do?:
do not get why adding QT widget class to project came up with this
QT -= guiLet me rephrase, especially the above.
I did say I understand what C +-= does.
(So why the sermon?)What I was asking - why is -= gui REMOVED ?
Is in not (qui) very common object AND and theory it should
read AKA leave it aloneQT += widgets
Besides - the wizard forgot to add widgets.
-
@AnneRanch Probably you select the option "Qt Console Application" (not "Qt Widgets Application") and gui is removed because Qt adds it by default but that type of project does not require them, on the other hand it does not have widgets because it is not included by default by Qt and being a project of console does not need widgets.
-
when a Qt project is created, core and gui are default settings.
Only when widgets are needed, you add widgets module.
It is unnecessary to remove
QT -= gui
and then add
QT += widgets
Both are needed actually.
QT += gui widgets
Originally, gui was used for widgets as well. Later, all widgets related classes were grouped into module widgets.