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. [SOLVED] Custom QML element init
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Custom QML element init

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.6k 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.
  • R Offline
    R Offline
    RaubTieR
    wrote on 31 Mar 2013, 21:00 last edited by
    #1

    I have a QML plugin, it exports the class "Window". This class has "width" and "height" properties. For some reason I have to recreate window to reflect any changes. I have a QML:
    @import Graphic 1.0 // my plugin
    Window
    {
    width: 800
    height: 600
    }@

    I know I could use QSize 800x600 to make it at once, but the given example represents the idea of separate properties (I have also fullscreen, etc,etc). How do I make my C++ class to automatically init() when, lets say "Component.onCompleted" happens? This is the code:
    @import Graphic 1.0 // my plugin
    import QtQuick 2.0 // for Component
    Window
    {
    width: 800
    height: 600
    Component.onCompleted: init()
    }@

    It basically does the job, but I want my interface to be more transparent, so user does not need to set this init() manually. Is this possible?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      beemaster
      wrote on 1 Apr 2013, 16:49 last edited by
      #2

      If your Window component is a subclass of QDeclarativeItem, you can override "QDeclarativeParserStatus::componentComplete":http://qt-project.org/doc/qt-4.8/qdeclarativeparserstatus.html#componentComplete

      1 Reply Last reply
      0
      • R Offline
        R Offline
        RaubTieR
        wrote on 3 Apr 2013, 17:41 last edited by
        #3

        Hm, thank you very much, I'll now go and derive from QDeclarativeParserStatus. I didn't want QDeclarativeItem because I don't need all of those built-in utils for visualization, but this status-class is exactly what I need.

        bq. QDeclarativeParserStatus provides a mechanism for classes instantiated by a QDeclarativeEngine to receive notification at key points in their creation. This class is often used for optimization purposes, as it allows you to defer an expensive operation until after all the properties have been set on an object.

        1 Reply Last reply
        0

        1/3

        31 Mar 2013, 21:00

        • 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