Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Qt6 QMake
Forum Updated to NodeBB v4.3 + New Features

Qt6 QMake

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
5 Posts 2 Posters 811 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jiej
    wrote on last edited by Jiej
    #1

    Hi,

    I've just installed Qt6 on Ubuntu using the command

    sudo apt install qt6-base-dev
    

    and when I create a Makefile with QMake6 for a simple C++ project that opens a QWidget, the compilation fails because it can't find QApplication header.

    The command executed by the makefile is

    g++ -c -pipe -O2 -Wall -Wextra -fPIC -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -I/usr/include/x86_64-linux-gnu/qt6 -I/usr/include/x86_64-linux-gnu/qt6/QtGui -I/usr/include/x86_64-linux-gnu/qt6/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt6/mkspecs/linux-g++ -o main.o main.cpp
    

    How to solve this ?

    Thank you

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      When you want to use widgets, you should specify it in your pro file.
      See e.g. https://doc.qt.io/qt-6/qlabel.html

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      J 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        When you want to use widgets, you should specify it in your pro file.
        See e.g. https://doc.qt.io/qt-6/qlabel.html

        J Offline
        J Offline
        Jiej
        wrote on last edited by
        #3

        @Christian-Ehrlicher Thank you for your reply.
        I think I did specify it in my .pro file but the compiler still can't find it.

        My project file is this one :

        TEMPLATE = app
        TARGET = main
        QT += core gui widgets
        CONFIG += c++11
        
        SOURCES += main.cpp
        
        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Your compiler output does not match the pro file. Rerun qmake on a clean build dir

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          J 1 Reply Last reply
          1
          • Christian EhrlicherC Christian Ehrlicher

            Your compiler output does not match the pro file. Rerun qmake on a clean build dir

            J Offline
            J Offline
            Jiej
            wrote on last edited by
            #5

            @Christian-Ehrlicher It worked.
            Thank you.
            This time QMake generated a different project file :

            ######################################################################
            # Automatically generated by qmake (3.1) Sun Dec 8 19:29:47 2024
            ######################################################################
            
            TEMPLATE = app
            TARGET = Qt_First_Project
            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
            

            I added QT += gui core widgets and the compilation was successful.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved