小编Ror*_*way的帖子

Qml - ReferenceError:屏幕未定义

尝试在学校制作一个小足球游戏作为一个项目,但我遇到了一些问题。因此,当我运行代码时,它说 ReferenceError: Screen is not defined,但根据我的说法,我已经定义了它。

这段代码只是一个原型,稍后会更改按钮的按键,以便它可以在手机上实际运行。

import QtQuick 2.0

Item {
    id:root

    width:Screen.width
    height:Screen.height-10
    focus:true

    Keys.onPressed: {

        if(event.key===Qt.Key_Up)
        {
            event.accepted = true;
            player.y=(player.y) - 40

        }
        if(event.Key === Qt.Key_Down){
            event.accepted = true;
            player.y = (player.y)+ 40
           }
        if (event.key === Qt.Key_Right)
         { event.accepted=true;
            player.x=(player.x)-40

        }
   if (event.key === Qt.Key_Left)
{event.accepted = true;
       player.x=(player.x) +40
   }

    }

Flickable {
    width:Screen.width
    height:Screen.height
    contentHeight: Screen.height*4
    contentWidth:Screen.width
    interactive:true
    boundsBehavior: Flickable.StopAtBounds

    Image{
        id: feild
        anchors.fill:parent
        source:"Namnlös.png"
        sourceSize.height:Screen.height*4
        sourceSize.width:Screen.width
        }

    Image {
        id: player
        source:"asd.png" …
Run Code Online (Sandbox Code Playgroud)

qml

4
推荐指数
1
解决办法
2868
查看次数

点击后按下拉菜单

我正在尝试在您点击菜单时让我的菜单停留,我的意思是在点击它之后保留下拉菜单.这是我已经尝试过的代码(下面是Javascript),但由于某种原因,它在现实中对我不起作用.所以我现在正在寻求帮助.

摆弄风格> http://jsfiddle.net/hRxRG/

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"xml:lang="sv">
<head>
  <title>Nösnäs</title>

        <link rel="stylesheet" type="text/css" href="screen.css" />
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'></script>
        <script src="script.js"></script>
</head>
<body>

<button class="nav-button">Toggle Navigation</button>

<ul class="nav">
<li class="program"><a href="#">Program</a>
<div class="second nav">
  <ul>
<li><a href="#">Teknik</a></li>
<li><a href="#">Naturvetenskap</a></li>
<li><a href="#">El</a></li>
</ul></li>
</div>
  <li><a href="#">Nösnäs</a></li>
  <li><a href="#">Schema</a></li>
  <li><a href="#">Matsal</a></li>
   </ul>






</body>
</html>






console.log("hej");

$(".program").on('click',function () {
console.log("hejssss");
                $('li div ul').toggle('.close');
                console.log("hejs");
                $('li div ul').show();

        });
Run Code Online (Sandbox Code Playgroud)

html javascript css drop-down-menu

0
推荐指数
1
解决办法
4416
查看次数

标签 统计

css ×1

drop-down-menu ×1

html ×1

javascript ×1

qml ×1