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. Qt Creator ignores QML-Prototype in custom Module
QtWS25 Last Chance

Qt Creator ignores QML-Prototype in custom Module

Scheduled Pinned Locked Moved QML and Qt Quick
create pluginmoduleqtcreatorqml
2 Posts 2 Posters 1.6k 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
    Tobias F
    wrote on 12 May 2015, 07:18 last edited by Tobias F 5 Dec 2015, 07:27
    #1

    Hi all,

    I've written a custom QML-Module and therein is a type called MyTextBlock.qml

    import QtQuick 2.3
    Text
    {
        verticalAlignment: Text.AlignVCenter
        font.pixelSize: 34
        font.weight: Font.Bold;
    }
    

    This type is inside a qrc file and is registered via a QQmlExtensionPlugin in the 'registerTypes' method in the following way

    qmlRegisterType(QUrl("qrc:/MyTextBlock.qml"), uri, 1, 0, "MyTextBlock");
    

    The qmldirof the extension plugin is

    module UiComponents
    plugin UiComponents
    typeinfo plugins.qmltypes
    

    and the generated plugins.types is

    import QtQuick.tooling 1.1
    
    // This file describes the plugin-supplied types contained in the library.
    // It is used for QML tooling purposes only.
    //
    // This file was auto-generated by:
    // 'qmlplugindump.exe UiComponents 1.0 D:\plugin\release\'
    
    Module {
        Component {
            prototype: "QQuickText"
            name: "UiComponents/MyTextBlock"
            exports: ["MyTextBlock 1.0"]
            exportMetaObjectRevisions: [0]
            isComposite: true
            defaultProperty: "data"
        }
    }
    
    

    Now I create a new QML-App and import the module and set the QML_IMPORT_PATH property inside the .pro file
    The main.qml file looks like

    import QtQuick 2.3
    import QtQuick.Window 2.2
    
    import UiComponents 1.0
    
    Window {
        visible: true
        width: 360
        height: 360
     
       MyTextBlock
    {
    color:"red"
    }
    
    

    The type MyTextBlock is recognized by QT-Creator and when I hover over the import statement QT-Creator gives me a "Read typeinfo file successfully" but it complains about the color property with the message Invalid property name "color"

    The applications itself runs fine but the error messages in QT-Creator are annoying. Is here something missing that must be done to support Qt-Creator?

    As a side note. I've also a pure c++ based QObject inside the module that's also registered and when I uses this object inside an application it's properties are not marked as invalid. Somehow I think QT-Creator ignorest the "inherited" parameters of the prototype of the type. (QQuickText in case of MyTextBlock)

    Regards
    Tobias

    1 Reply Last reply
    0
    • P Offline
      P Offline
      pcspets
      Qt Champion 2021
      wrote on 20 Mar 2019, 14:29 last edited by
      #2

      Indeed, QtCreator seems to ignore the "prototype" member in .qmltypes because the file is generated correctly.

      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