首页下载资源后端QML使用C++定义枚举

ZIPQML使用C++定义枚举

shorlly5.85KB需要积分:1

资源文件列表:

EnumTester.zip 大约有9个文件
  1. EnumTester/
  2. EnumTester/EnumTest.qml 1.95KB
  3. EnumTester/EnumTester.pro 696B
  4. EnumTester/EnumTester.pro.user 19.27KB
  5. EnumTester/EnumTester.qrc 96B
  6. EnumTester/main.cpp 380B
  7. EnumTester/mainwindow.cpp 1.2KB
  8. EnumTester/mainwindow.h 818B
  9. EnumTester/mainwindow.ui 723B

资源介绍:

QML使用C++定义枚举样例代码
#include "mainwindow.h" #include "ui_mainwindow.h" #include #include #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); initQmlWidget(); } MainWindow::~MainWindow() { delete ui; } void MainWindow::initQmlWidget() { m_pQmlView = new QQuickView(); m_pQmlView->setSource(QUrl("qrc:/EnumTest.qml")); m_pQmlPanel = (QQuickWidget*)QWidget::createWindowContainer(m_pQmlView,this); m_pContext = m_pQmlView->rootContext(); m_pQmlPanel->show(); } void MainWindow::resizeEvent(QResizeEvent* e) { m_pQmlPanel->setGeometry(rect()); m_pContext->setContextProperty("appMainWindow", this); } void MainWindow::callFun(FunType funType) { QString strMsg = tr("当前颜色"); switch(funType){ case FunType::RED: strMsg += tr("红色"); break; case FunType::YELLOW: strMsg += tr("黄色"); break; case FunType::BLUE: strMsg += tr("蓝色"); break; default: strMsg += QStringLiteral("无选项"); } QMessageBox::information(this,"info",strMsg); }
100+评论
captcha