From a3041feaa4a1b649fc19311aee22d92d56e0d735 Mon Sep 17 00:00:00 2001 From: xmuli Date: Fri, 2 Jul 2021 01:47:43 +0800 Subject: [PATCH] feat: QtComboModeShow --- QtComboModeShow/QtComboModeShow.pro | 16 ++++++++++++ QtComboModeShow/main.cpp | 39 +++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 QtComboModeShow/QtComboModeShow.pro create mode 100644 QtComboModeShow/main.cpp diff --git a/QtComboModeShow/QtComboModeShow.pro b/QtComboModeShow/QtComboModeShow.pro new file mode 100644 index 0000000..197e5fc --- /dev/null +++ b/QtComboModeShow/QtComboModeShow.pro @@ -0,0 +1,16 @@ +QT -= gui + +CONFIG += c++11 console +CONFIG -= app_bundle + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + main.cpp + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/QtComboModeShow/main.cpp b/QtComboModeShow/main.cpp new file mode 100644 index 0000000..7979a2f --- /dev/null +++ b/QtComboModeShow/main.cpp @@ -0,0 +1,39 @@ +#include +#include +using namespace std; + + +class A +{ +public: + + void add(A *pt){ m_v.push_back(pt); } + + QVector m_v; + QString m_name; +}; + +class B : public A +{ +public: + void add(A *pt){ m_v.push_back(pt); } +}; + + +class C : public A +{ +public: +}; + +int main(int argc, char *argv[]) +{ + A ma1; + B mb1, mb2, mb3, mb4; + C mc1, mc2, mc3; + + ma1.add(&mb1); ma1.add(&mb3); + mb1.add(&mc1); mb1.add(&mb2); + mb3.add(&mc2); mb3.add(&mc3); mb3.add(&mb4); + + return 0; +}