咨询下,tabview 下的 tab里KeyNavigation的用法。



  • 咨询下,tabview 下的 tab里KeyNavigation的用法。
    ![0_1482128260809_111.gif](正在上传 100%)
    官方的例子,用键盘上下键,选择一个控件的焦点·
    想在tabview 下用,单独的tab 里用 就不行了·

    import QtQuick 2.0
    import QtQuick.Controls 1.4
    
    TabView{
        id:meun_TabView;
        width:  300;
        height: 480;
        focus: true;
        activeFocusOnTab : true;
    
      Tab {
           id:aa;
           title: "111"	   	 
            Column {
        
                Rectangle {
                    id: topLeft
                    width: 50; height: 50
                    color: focus ? "red" :"lightgray"
                    focus: true	;					
                    KeyNavigation.down: topRight
                    
                }
    
                Rectangle {
    
                    id: topRight
                    width: 50; height: 50
                    color: focus ? "red" :"lightgray"  
                    focus: true	;								
                    KeyNavigation.down: bottomLeft
    
                }				 
                Rectangle {
    
                    id: bottomLeft
                    width: 50; height: 50
                    color: focus ? "red" :"lightgray"
                    focus: true	;	
                    KeyNavigation.down: bottomRight
    
                }
    
                Rectangle {
    
                    id: bottomRight
                    width: 50; height: 50
                    color: focus ? "red" :"lightgray"
                    focus: true	;								
                    KeyNavigation.down:topLeft
    
                }
            }		
         }
        Tab {
               id:bb;
               title: "222"
        }
               
        Tab {
               id:cc;
               title: "333"
        }		   	   
    }
    


  • import QtQuick 2.0
    import QtQuick.Controls 1.4
    
    TabView{
        id:meun_TabView;
        width:  300;
        height: 480;
    
        activeFocusOnTab : true
    
        Tab {
            id:aa;
            title: "111"
    
            Column {
    
                Rectangle {
                    id: topLeft
                    width: 50; height: 50
                    color: focus ? "red" :"lightgray"
                    focus: true
    
                    KeyNavigation.down: topRight
                    Keys.onPressed: {
                        console.log("press");
                    }
    
                    Component.onCompleted: {
                        // 这里可以强制topLeft 获取键盘焦点。
                        topLeft.forceActiveFocus();
                    }
    
                }
    
                Rectangle {
    
                    id: topRight
                    width: 50; height: 50
                    color: focus ? "red" :"lightgray"
    
                    KeyNavigation.down: bottomLeft
    
                }
                Rectangle {
    
                    id: bottomLeft
                    width: 50; height: 50
                    color: focus ? "red" :"lightgray"
    
                    KeyNavigation.down: bottomRight
    
                }
    
                Rectangle {
    
                    id: bottomRight
                    width: 50; height: 50
                    color: focus ? "red" :"lightgray"
    
                    KeyNavigation.down:topLeft
    
                }
            }
        }
        Tab {
            id:bb;
            title: "222"
        }
    
        Tab {
            id:cc;
            title: "333"
        }
    }
    


  • 谢谢了!可以了!


Log in to reply
 

走马观花

最近的回复

  • 🥚 🥒 🥚

    read more
  • 论坛似乎更换了新的表情呢。我试试看看?♂ ♂ :smiling_face_with_open_mouth_closed_eyes:

    read more
  • 最近尝试将我们动作编辑器的部分装入NDK中,出现了很难解决的问题。导致进行不下去了,后面发现是NDK库调用约定的问题。最后只得发现,只能使用C调用约定才能够顺利地链接成功。☹

    read more
  • qmake输出 warning: winrt_manifest_install.path is not defined: install target not created.

    运行直接报错 Cannot establish connection to the WinRT debugging helper.

    大佬们,我是不是缺什么组件还是怎么回事啊?

    read more

关注我们

微博
QQ群