<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

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

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

          作者: 時(shí)間: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)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();