mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-06 17:25:24 +08:00
qt 6.5.1 original
This commit is contained in:
26
tests/auto/cmake/test_moc_macro_target/CMakeLists.txt
Normal file
26
tests/auto/cmake/test_moc_macro_target/CMakeLists.txt
Normal file
@ -0,0 +1,26 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(test_moc_macro_target)
|
||||
|
||||
find_package(Qt6Core REQUIRED)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
qt_generate_moc(main_gen_test.cpp
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/main_gen_test.moc"
|
||||
TARGET QtGenerateMacroTest
|
||||
)
|
||||
add_executable(QtGenerateMacroTest main_gen_test.cpp "${CMAKE_CURRENT_BINARY_DIR}/main_gen_test.moc")
|
||||
target_include_directories(QtGenerateMacroTest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface")
|
||||
target_link_libraries(QtGenerateMacroTest PRIVATE Qt6::Core)
|
||||
|
||||
qt_wrap_cpp(moc_file mywrapobject.h
|
||||
TARGET QtWrapMacroTest
|
||||
)
|
||||
add_executable(QtWrapMacroTest main_wrap_test.cpp ${moc_file})
|
||||
target_include_directories(QtWrapMacroTest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface")
|
||||
target_link_libraries(QtWrapMacroTest PRIVATE Qt::Core)
|
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#ifndef MYINTERFACE_H
|
||||
#define MYINTERFACE_H
|
||||
|
||||
#include <qglobal.h>
|
||||
|
||||
class MyInterface
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
Q_DECLARE_INTERFACE(MyInterface, "org.cmake.example.MyInterface")
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
23
tests/auto/cmake/test_moc_macro_target/main_gen_test.cpp
Normal file
23
tests/auto/cmake/test_moc_macro_target/main_gen_test.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "myinterface.h"
|
||||
|
||||
class MyObject : public QObject, MyInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MyInterface)
|
||||
public:
|
||||
explicit MyObject(QObject *parent = nullptr) : QObject(parent) { }
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
MyObject mo;
|
||||
mo.objectName();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "main_gen_test.moc"
|
13
tests/auto/cmake/test_moc_macro_target/main_wrap_test.cpp
Normal file
13
tests/auto/cmake/test_moc_macro_target/main_wrap_test.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "mywrapobject.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
MyWrapObject mwo;
|
||||
mwo.objectName();
|
||||
return 0;
|
||||
}
|
19
tests/auto/cmake/test_moc_macro_target/mywrapobject.h
Normal file
19
tests/auto/cmake/test_moc_macro_target/mywrapobject.h
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright (C) 2013 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#ifndef MYWRAPOBJECT_H
|
||||
#define MYWRAPOBJECT_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "myinterface.h"
|
||||
|
||||
class MyWrapObject : public QObject, MyInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MyInterface)
|
||||
public:
|
||||
explicit MyWrapObject(QObject *parent = nullptr) : QObject(parent) { }
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user