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. Custom type reference fails with <customControl> is not a type. Why?
Forum Updated to NodeBB v4.3 + New Features

Custom type reference fails with <customControl> is not a type. Why?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 404 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    Stokestack
    wrote on 19 Jun 2019, 20:22 last edited by Stokestack
    #1

    Hi all. New to Qt Quick and QML. Following a tutorial in a book, but it's failing and I don't know why.

    I have two QML files...

    MyToolbar.qml:

    import QtQuick 2.12
    
    Rectangle
    {
    	color: "gray"
    	height: 50
    
    	Rectangle
    	{
    		id: purpleRectangle
    		width: 50; height: parent.height
    		color: "purple"
    		radius: 10
    	}
    
    	Text
    	{
    		anchors.left: purpleRectangle.right
    		anchors.right: parent.right
    		text: "hello there."
    		font.pointSize: 30
    	}
    }
    

    and then main.qml

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick.Layouts 1.12
    
    Window
    {
    	visible: true
    	width: 640; height: 480
    
    	Rectangle
    	{
    		width: 200; height: 200
    		color: "red"
    	}
    
    	MyToolbar
    	{
    		id: myToolbar
    		width: parent.width
    	}
    
    	RowLayout
    	{
    		anchors.top: myToolbar.bottom
    		anchors.left: parent.left
    		anchors.right: parent.right
    		anchors.bottom: parent.bottom
    	}
    }
    

    Both files are in the project file. This fails with

    W libgallery-mobile.so: QQmlApplicationEngine failed to load component
    W libgallery-mobile.so: qrc:/main.qml:16 MyToolbar is not a type
    

    I don't see anything missing from what the book shows. Any ideas? Thanks!

    Additional note: This looks a bit suspicious, with MyToolbar.qml not under Resources. But I don't know how this folder is populated:

    0_1560976291607_Screen Shot 2019-06-19 at 1.29.27 PM.png

    1 Reply Last reply
    0
    • N Offline
      N Offline
      Nifiro
      wrote on 19 Jun 2019, 20:33 last edited by
      #2

      0_1560976409147_fd419141-ffb1-45a2-bcbf-72e59738b259-image.png

      S 1 Reply Last reply 19 Jun 2019, 20:44
      1
      • N Nifiro
        19 Jun 2019, 20:33

        0_1560976409147_fd419141-ffb1-45a2-bcbf-72e59738b259-image.png

        S Offline
        S Offline
        Stokestack
        wrote on 19 Jun 2019, 20:44 last edited by Stokestack
        #3

        @Nifiro Thanks for the reply. I had tried that at the Resources level, but got a blanket "Couldn't add..." error with no explanation. Also tried dragging, which doesn't work.

        Any idea why Qt Creator lets you create QML files and then adds them to a "QML" folder but not to the resources?

        1 Reply Last reply
        0

        1/3

        19 Jun 2019, 20:22

        • Login

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