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 QML objects
Forum Updated to NodeBB v4.3 + New Features

Custom QML objects

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 584 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.
  • T Offline
    T Offline
    Tikani
    wrote on last edited by
    #1

    Hi! :) How to create new objects in QML, utilizing all benefits of programming in object-oriented environment? I want to create a class inheriting Popup with ability of displaying short videos while hover some element in application window. Thanks in advance.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @Tikani

      How to create new objects in QML, utilizing all benefits of programming in object-oriented environment?

      Please refer http://doc.qt.io/qt-5/qtqml-javascript-dynamicobjectcreation.html

      I want to create a class inheriting Popup with ability of displaying short videos while hover some element in application window.

      You can create a custom component which will instantiate Popup. In this custom component you can add your own properties and methods which will be accessible when you instantiate your custom component.
      For eg.:
      MyPopup.qml

      import QtQuick 2.7
      import QtQuick.Controls 2.0
      
      Popup {
          property string property1: "abc"
          property bool property2: true
          property int property3: 100
      
          x: 100
          y: 100
          width: 200
          height: 300
          modal: true
          focus: true
          closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
      }
      

      Using MyPopup

      Window {
          id: window
          width: 400
          height: 400
          visible: true
      
          Button {
              text: "Open"
              onClicked: popup.open()
          }
      
          MyPopup {
              id: popup
          }
      }
      

      157

      1 Reply Last reply
      2

      • Login

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