Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-48840

Not all methods of a QWidget are available from a QJSEngine

    XMLWordPrintable

Details

    Description

      If you pass a QWidget as a property to a QJSEngine/QQmlEngine, the following methods/properties of a QWidget are available:

      [
          "objectName",
          "modal",
          "windowModality",
          "enabled",
          "geometry",
          "frameGeometry",
          "normalGeometry",
          "x",
          "y",
          "pos",
          "frameSize",
          "size",
          "width",
          "height",
          "rect",
          "childrenRect",
          "childrenRegion",
          "sizePolicy",
          "minimumSize",
          "maximumSize",
          "minimumWidth",
          "minimumHeight",
          "maximumWidth",
          "maximumHeight",
          "sizeIncrement",
          "baseSize",
          "palette",
          "font",
          "cursor",
          "mouseTracking",
          "isActiveWindow",
          "focusPolicy",
          "focus",
          "contextMenuPolicy",
          "updatesEnabled",
          "visible",
          "minimized",
          "maximized",
          "fullScreen",
          "sizeHint",
          "minimumSizeHint",
          "acceptDrops",
          "windowTitle",
          "windowIcon",
          "windowIconText",
          "windowOpacity",
          "windowModified",
          "toolTip",
          "toolTipDuration",
          "statusTip",
          "whatsThis",
          "accessibleName",
          "accessibleDescription",
          "layoutDirection",
          "autoFillBackground",
          "styleSheet",
          "locale",
          "windowFilePath",
          "inputMethodHints",
          "objectNameChanged",
          "windowTitleChanged",
          "windowIconChanged",
          "windowIconTextChanged",
          "customContextMenuRequested",
          "setEnabled",
          "setDisabled",
          "setWindowModified",
          "setWindowTitle",
          "setStyleSheet",
          "setFocus",
          "update",
          "repaint",
          "setVisible",
          "setHidden",
          "show",
          "hide",
          "showMinimized",
          "showMaximized",
          "showFullScreen",
          "showNormal",
          "close",
          "raise",
          "lower",
          "updateMicroFocus",
          "grab",
          "grab"
      ]
      

      Quite a few are exposed, but it's missing a few like the ability to get/set the: layout, parent, children, button and label text, and properties. There might be a few more on a per-widget basis, but those are the ones that stood out the most to me.

      People wanting to do this from JS could do what I did for now and make a function that takes the widget/layout/etc as its arguments and do the operation from the C++ side of things. Example:

      injectedQObject.setWidgetLayout(aQWidget, aQWidgetLayout);
      injectedQObject.setWidgetProperty(aQWidget, 'propertyName', "propertyValue");
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            empyrical empyrical
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes