Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Problem with using components between files
Forum Updated to NodeBB v4.3 + New Features

Problem with using components between files

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 185 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Traust
    wrote on last edited by Traust
    #1

    When I'm trying to use code from file Animation.qml in other file, I get an error, I use it in other file like this
    ea49788c-7b16-49c7-86a6-ee5ea6f1fa17-image.png

    d04c8369-f878-4eec-8b47-02f858314d62-image.png

    Also I'm wondering if there is better way to use components from other files, cause sometimes I want one or few things, not whole code and by using it like with this Animation.qml file, I always add visible: false, so it doesnt show up

    Animation.qml

    import QtQuick 2.2
    
    Item {
        property bool accelerating: false
        property int gear: 1
    
        function gears(gear){
            if(gear === 1){
                return 80
            }
            if (gear === 2){
                return 55
            }
            if (gear === 3){
                return 38
            }
            if (gear === 4){
                return 27
            }
            if (gear === 5){
                return 22
            }
            if (gear === 6){
                return 15
            }
    
        }
    
        Keys.onSpacePressed: accelerating = true
    
        Keys.onReleased: {
            if (event.key === Qt.Key_Space) {
                accelerating = false;
                event.accepted = true;
            }
        }
        Keys.onUpPressed:{
            if(gear === 6){
    
            }else{
                gear++
                //console.log("Gear: " + gear.toString())
            }
    
    
    
        }
        Keys.onDownPressed:{
            if (gear === 1){
    
            }else{
                gear--
                //console.log("Gear: " + gear.toString())
            }
    
    
        }
    
    }
    
    1 Reply Last reply
    0
    • eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by
      #2

      There is already a component called Animation so your component is crashing, try changing the name of your component.

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved