• <bdo id='hfbh0'></bdo><ul id='hfbh0'></ul>

      <tfoot id='hfbh0'></tfoot>

    1. <i id='hfbh0'><tr id='hfbh0'><dt id='hfbh0'><q id='hfbh0'><span id='hfbh0'><b id='hfbh0'><form id='hfbh0'><ins id='hfbh0'></ins><ul id='hfbh0'></ul><sub id='hfbh0'></sub></form><legend id='hfbh0'></legend><bdo id='hfbh0'><pre id='hfbh0'><center id='hfbh0'></center></pre></bdo></b><th id='hfbh0'></th></span></q></dt></tr></i><div id='hfbh0'><tfoot id='hfbh0'></tfoot><dl id='hfbh0'><fieldset id='hfbh0'></fieldset></dl></div>
      <legend id='hfbh0'><style id='hfbh0'><dir id='hfbh0'><q id='hfbh0'></q></dir></style></legend>

      <small id='hfbh0'></small><noframes id='hfbh0'>

      1. Android后退按钮按下不会触发keys.onreleased qml

        时间:2023-11-09
        <tfoot id='xlz1Q'></tfoot>
      2. <i id='xlz1Q'><tr id='xlz1Q'><dt id='xlz1Q'><q id='xlz1Q'><span id='xlz1Q'><b id='xlz1Q'><form id='xlz1Q'><ins id='xlz1Q'></ins><ul id='xlz1Q'></ul><sub id='xlz1Q'></sub></form><legend id='xlz1Q'></legend><bdo id='xlz1Q'><pre id='xlz1Q'><center id='xlz1Q'></center></pre></bdo></b><th id='xlz1Q'></th></span></q></dt></tr></i><div id='xlz1Q'><tfoot id='xlz1Q'></tfoot><dl id='xlz1Q'><fieldset id='xlz1Q'></fieldset></dl></div>

      3. <small id='xlz1Q'></small><noframes id='xlz1Q'>

            <bdo id='xlz1Q'></bdo><ul id='xlz1Q'></ul>
              • <legend id='xlz1Q'><style id='xlz1Q'><dir id='xlz1Q'><q id='xlz1Q'></q></dir></style></legend>
                    <tbody id='xlz1Q'></tbody>
                1. 本文介绍了Android后退按钮按下不会触发keys.onreleased qml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 Qt5.3 和 Qtquick2.1 创建一个程序.我正在尝试使用 Keys.onReleased 在我的代码中捕获 android 上的后退按钮按下.但是该事件没有被触发.此外,我已将项目焦点设置为 true.但仍然没有成功.这是代码示例

                  I am creating a program in Qt5.3 and Qtquick2.1. I am trying to capture back button press on android in my code using Keys.onReleased. But that event is not getting triggered. Also I have set the item focus to true. But still no success. Here is the code sample

                  import QtQuick 2.1
                  import QtQuick.Controls 1.2
                  import QtQuick.Controls.Styles 1.2
                  import QtQuick.Layouts 1.1
                  import QtQuick.Window 2.1
                  
                  Rectangle
                  {
                      id: main2
                      focus: true
                      width: Screen.Width
                      height: Screen.Height
                      Keys.enabled: true
                      Keys.priority: Keys.BeforeItem
                  
                      property string load_page: ""
                      signal deskConnected()
                  
                      Loader{
                          id: pageloader
                          anchors.fill: parent
                          source: "qrc:/qml/resources/Firstpage.qml"
                      }
                  
                      onDeskConnected: {
                           pageloader.item.onDeskConnected()
                      }
                  
                      function loadPatwin(){
                          pageloader.source = "qrc:/qml/resources/Secondpage.qml";
                      }
                  
                      Keys.onReleased: {
                          console.log("back");
                          if (event.key === Qt.Key_Back) {
                              event.accepted=true;
                          }
                      }
                  }
                  

                  这里的 loadPatwin 是在按下某个其他 qml 中定义的按钮时调用的函数.并加载一个新的 qml.但在那之后,当我按下 android 上的后退按钮时,应用程序被关闭,它甚至不会在日志中打印后退".有什么建议我在这里做错了吗?

                  Here loadPatwin is the function which gets called on pressing a button which is defined in some other qml. And loads a new qml. But after that when I am pressing the back button on android, the app gets closed and it doesn't print even "back" in the logs. Any suggestions what I am doing wrong here?

                  提前致谢.

                  推荐答案

                  在qt quick(Qt5.1及更高版本)中,ApplicationWindowWindow,都有一个<当用户在 android 中触摸后退按钮时发出的 code>closure 信号.您可以简单地实现一个 onClosing 处理程序并将 close 参数设置为 false.操作方法如下:

                  In qt quick (Qt5.1 and later) the ApplicationWindow and Window, both have a closing signal that is emitted when the user touches the back button in android. You can simply implement an onClosing handler and set the close parameter to false. Here is how to do it:

                  onClosing: {
                      close.accepted = false
                  }
                  

                  通过这个处理程序,您可以轻松管理 android 设备的后退按钮.它不需要任何额外的许可.例如,假设您有一个 StackView 来管理 GUI.您可以编写这些代码行,然后您的应用程序的行为就像原生 android 应用程序一样:

                  By this handler you can easily manage the back button of android device. It does not need any extra permission. For example suppose you have a StackView to manage the GUI. You can write these lines of code, Then your application behaves as like as a native android app:

                  onClosing: {
                          if(stack.depth > 1){
                              close.accepted = false
                              stack.pop();
                          }else{
                              return;
                          }
                      }
                  

                  这篇关于Android后退按钮按下不会触发keys.onreleased qml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:iOS UIWebView 应用在 Safari 中打开链接 下一篇:如何使 QML TextField 绑定在 Android 下工作?

                  相关文章

                  1. <i id='INBGx'><tr id='INBGx'><dt id='INBGx'><q id='INBGx'><span id='INBGx'><b id='INBGx'><form id='INBGx'><ins id='INBGx'></ins><ul id='INBGx'></ul><sub id='INBGx'></sub></form><legend id='INBGx'></legend><bdo id='INBGx'><pre id='INBGx'><center id='INBGx'></center></pre></bdo></b><th id='INBGx'></th></span></q></dt></tr></i><div id='INBGx'><tfoot id='INBGx'></tfoot><dl id='INBGx'><fieldset id='INBGx'></fieldset></dl></div>

                      <bdo id='INBGx'></bdo><ul id='INBGx'></ul>

                      <legend id='INBGx'><style id='INBGx'><dir id='INBGx'><q id='INBGx'></q></dir></style></legend>

                    1. <small id='INBGx'></small><noframes id='INBGx'>

                      <tfoot id='INBGx'></tfoot>