-1

I install Qtcreator and Qt5 itself via Msys2 using this guide https://wiki.qt.io/MinGW-64-bit

When i try import QWidgets via

#include <QtWidgets

It says No such file or directory I think i need install more Qt5 packages that contain QWidgets, but i cant find info about that.

I use Qt Creator 4.10.2 based on Qt 5.13.2

Vasilij Altunin
  • 754
  • 1
  • 5
  • 18

1 Answers1

0

I figured out problem:

I just change my CMakeLists.txt file

cmake_minimum_required(VERSION 3.5)

project(t2 LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_PREXIX_PATH C:\\msys64\\mingw64)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)


set(CMAKE_CXX_COMPILER_FORCED TRUE)

file(GLOB src_files
    "*.h"
    "*.cpp"
)


find_package(Qt5 COMPONENTS Core Quick QuickControls2 Widgets REQUIRED)


add_executable(t2 main.cpp qml.qrc ${src_files})

target_compile_definitions(t2
  PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)

  target_link_libraries(t2
  PRIVATE Qt5::Core Qt5::Quick Qt5::QuickControls2 Qt5::Widgets)

by adding Widgets and Qt5::Widgets and now i can use C++ code with QWidgets

Vasilij Altunin
  • 754
  • 1
  • 5
  • 18
  • Also keep in mind there 2 different type of projects in Qtcreator - Qt Widgets Applicatopn and Qt Quick Application! They have different widgets and different GUI editors! – Vasilij Altunin Dec 23 '19 at 23:41