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

QMLBridges: AutoQmlBridge()

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P2: Important
    • None
    • None
    • QML: Bridges
    • None

    Description

      Implement a skeleton version of AutoQmlBridge() to be made available in the PySide6.Qml modules that when wrapped across a type, should enable that type to be used from QML. This type should also be comptaible with QAbstractItemModel, so that it can be used with the View classes.

      Example:

      // main.py
      
      from PySide6.Qml import AutoQmlBridge
      
      class WeatherDataModel:    
           def add_string(self, new_string: str):        
              # Example method to demonstrate slot wrapping        
              print(f"Added {new_string}")        
      
      AutoQmlBridge(weather_data_model, data_type="List")
      
      
       // main.qml
      import backend 1.0 
      ApplicationWindow { 
      Column { 
      anchors.centerIn: parent 
      TextField { 
      id: inputField placeholderText: "Enter a string"
       } 
      Button {
       text: "Add String" 
      onClicked: {            
               WeatherDataModel.add_string(inputField.text) 
      } }   
      } }
      

       

      Attachments

        Issue Links

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

          Activity

            People

              shpremna Shyamnath Premnadh
              shpremna Shyamnath Premnadh
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes