色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > Qt on Android:使用JNI與第三方j(luò)ar包

          Qt on Android:使用JNI與第三方j(luò)ar包

          作者: 時間:2016-09-12 來源:網(wǎng)絡(luò) 收藏

          QHBoxLayout *getLayout = new QHBoxLayout();

          layout->addLayout(getLayout);

          m_urlEdit = new QLineEdit(http://blog.csdn.net/foruok);

          getLayout->addWidget(m_urlEdit, 1);

          QPushButton *getButton = new QPushButton(GET);

          getLayout->addWidget(getButton);

          connect(getButton, SIGNAL(clicked()), this, SLOT(onGet()));

          m_resultView = new QTextEdit();

          m_resultView->setReadOnly(true);

          layout->addWidget(m_resultView, 1);

          m_stateLabel = new QLabel();

          layout->addWidget(m_stateLabel);

          }

          Widget::~Widget()

          {

          }

          bool Widget::event(QEvent *e)

          {

          if(e->type() == SimpleCustomEvent::eventType())

          {

          e->accept();

          SimpleCustomEvent *sce = (SimpleCustomEvent*)e;

          switch(sce->m_arg1)

          {

          case 1:

          m_resultView->setText(sce->m_arg2);

          m_stateLabel->setText(Success!);

          break;

          case 0:

          m_resultView->setText(sce->m_arg2);

          m_stateLabel->setText(Failed!);

          break;

          case -1:

          m_stateLabel->setText(sce->m_arg2);

          break;

          }

          return true;

          }

          return QWidget::event(e);

          }

          void Widget::onGet()

          {

          #ifdef WIN32

          m_resultView->setText(Sorry, Just for Android!);

          #elif defined(ANDROID)

          QString url = m_urlEdit->text();

          QAndroidJniObject javaAction = QAndroidJniObject::fromString(url);

          QAndroidJniObject::callStaticMethod(an/qt/useJar/ExtendsQtWithJava,

          downloadWebPage,

          (Ljava/lang/String;)V,

          javaAction.object());

          m_stateLabel->setText(Downloading...);

          #endif

          }

          調(diào)用Java的代碼在onGet()槽中,很簡單,不解釋了。有疑問看Qt幫助手冊有關(guān)QAndroidJniObject類的說明。

          OK,到此結(jié)束。


          上一頁 1 2 3 下一頁

          關(guān)鍵詞:

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉