I am going to assume you are using the Qt versions installed by the online installer. On Linux this creates a folder Qt containing one folder for each Qt library version you chose to install (and some other stuff to support Qt Creator). For example:
chrisw@newton:~/Qt$ ls -l
total 31492
drwxrwxr-x 3 chrisw chrisw 4096 Jun 8 2020 5.15.0
drwxrwxr-x 3 chrisw chrisw 4096 Jun 20 13:24 6.1.1
-rw-r--r-- 1 chrisw chrisw 10174 Jul 4 12:48 components.xml
...
Inside each Qt version folder is a complete set of Qt library components and tools identified by compiler(s):
chrisw@newton:~/Qt$ ls -l 5.15.0/
total 8
drwxrwxr-x 13 chrisw chrisw 4096 Jun 8 2020 gcc_64
-rw-rw-r-- 1 chrisw chrisw 2271 May 14 2020 sha1s.txt
chrisw@newton:~/Qt$ ls -l 5.15.0/gcc_64/
total 76
drwxr-xr-x 2 chrisw chrisw 4096 Jun 8 2020 bin
drwxr-xr-x 4 chrisw chrisw 4096 Jun 8 2020 doc
drwxr-xr-x 88 chrisw chrisw 4096 Jun 8 2020 include
drwxr-xr-x 5 chrisw chrisw 28672 Jun 8 2020 lib
drwxr-xr-x 2 chrisw chrisw 4096 Jun 8 2020 libexec
drwxr-xr-x 76 chrisw chrisw 4096 Jun 8 2020 mkspecs
drwxr-xr-x 2 chrisw chrisw 4096 Jun 8 2020 phrasebooks
drwxr-xr-x 33 chrisw chrisw 4096 Jun 8 2020 plugins
drwxr-xr-x 23 chrisw chrisw 4096 Jun 8 2020 qml
drwxr-xr-x 2 chrisw chrisw 4096 Jun 8 2020 resources
drwxr-xr-x 3 chrisw chrisw 12288 Jun 8 2020 translations
If you run the qmake executable from the ~Qt/5.15.0/gcc_64/bin folder against your PRO file it will generate a Makefile that uses the tools and library under ~Qt/5.15.0/gcc_64 and the (in this example) the 64-bit GCC compiler. When you run make your project will be built with those tools and libraries. A Windows install will be similar but you may need to ensure the bundled MingW bin folder is in your PATH.
So, from top to bottom:
chrisw@newton:/tmp/demo$ cat main.cpp
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char **argv) {
QCoreApplication app(argc, argv);
qDebug() << "Excellent!";
return 0;
}
A basic PRO file starter can be created for you (one time only, after that you maintain this file yourself):
chrisw@newton:/tmp/demo$ ~/Qt/5.15.0/gcc_64/bin/qmake -project
chrisw@newton:/tmp/demo$ cat demo.pro
######################################################################
# Automatically generated by qmake (3.1) Sat Aug 28 09:32:14 2021
######################################################################
TEMPLATE = app
TARGET = demo
INCLUDEPATH += .
# You can make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# Please consult the documentation of the deprecated API in order to know
# how to port your code away from it.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Input
SOURCES += main.cpp
Then you create the Makefile:
chrisw@newton:/tmp/demo$ ~/Qt/5.15.0/gcc_64/bin/qmake
chrisw@newton:/tmp/demo$ ls
demo.pro main.cpp Makefile
and build the project:
chrisw@newton:/tmp/demo$ make
g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -I/home/chrisw/Qt/5.15.0/gcc_64/include -I/home/chrisw/Qt/5.15.0/gcc_64/include/QtGui -I/home/chrisw/Qt/5.15.0/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I/home/chrisw/Qt/5.15.0/gcc_64/mkspecs/linux-g++ -o main.o main.cpp
g++ -Wl,-O1 -Wl,-rpath,/home/chrisw/Qt/5.15.0/gcc_64/lib -o demo main.o /home/chrisw/Qt/5.15.0/gcc_64/lib/libQt5Gui.so /home/chrisw/Qt/5.15.0/gcc_64/lib/libQt5Core.so -lGL -lpthread
chrisw@newton:/tmp/demo$ ./demo
Excellent!