Reputation: 15
using the following configuration
I created my first source example in Qt6 with the following code
CMakeLists.txt (New version)
cmake_minimum_required(VERSION 3.5)
project(Test2 VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_PREFIX_PATH "/usr/lib/aarch64-linux-gnu/cmake/Qt6")
find_package(Qt6 REQUIRED COMPONENTS Widgets)
set(PROJECT_SOURCES
main.cpp
mainwindow.cpp
mainwindow.h
mainwindow.ui
)
qt_add_executable(Test2 MANUAL_FINALIZATION ${PROJECT_SOURCES})
target_link_libraries(Test2 PRIVATE Qt6::Widgets)
qt_finalize_executable(Test2)
mainwindow.cpp
#include "mainwindow.h"
#include "./ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
during compilation, the error appears
QMainWindow: File or directory does not exist
4 | #include <QMainWindow> | ^~~~~~~~~~~~~
compilation terminated.
can you help me ? Thank you all
My first example in Qt6
Upvotes: 0
Views: 279