I'm trying to have a Qt C environnement on visual studio code with cmake. Without Qt everything works perfectly but when I want to use an object Qt, I got no output on the console (with cout or qDebug()) and the GUI doesn't appear.
This is my code :
#include <iostream>
#include <QApplication>
#include <QMainWindow>
#include <QDebug>
int main(int argc, char *argv[]) {
std::cout << "My app" << std::endl;
qDebug() << "My app";
QApplication app(argc, argv);
QMainWindow msiWindow;
msiWindow.show();
return app.exec();
}
When I run it, I got no issue but nothing happen.
Here is my CMakeList.txt :
cmake_minimum_required(VERSION 3.17.3)
project(C )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c 17")
set(CMAKE_C_COMPILER "C:/Qt/Tools/mingw810_64/bin/gcc.exe")
set(CMAKE_CXX_COMPILER "C:/Qt/Tools/mingw810_64/bin/g .exe")
find_package(Qt6 COMPONENTS Widgets REQUIRED)
set(SOURCES
main.cpp)
add_executable( main ${SOURCES})
target_link_libraries(main PRIVATE Qt6::Widgets)
My c_cpp_properties.json if needed:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"C:/Qt/6.2.0/Src",
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:/Qt/Tools/mingw810_64/bin/gcc.exe",
"cStandard": "gnu17",
"cppStandard": "gnu 14",
"intelliSenseMode": "windows-gcc-x64",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
Please tell me if you have any idea.
CodePudding user response:
So I found my issue, I just forgot to add "C:\Qt\6.2.0\mingw81_64\bin"
to my PATH
environment variable.