Created
May 16, 2018 20:30
-
-
Save eyllanesc/f409000c86673dafa263fe3b5d67fb01 to your computer and use it in GitHub Desktop.
50314865
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
from PySide2.QtCore import Qt, QObject, Signal, Slot, Property | |
from PySide2.QtWidgets import QApplication | |
from PySide2.QtQml import QQmlApplicationEngine | |
my_list = ['here','is','my','list'] | |
class Manager(QObject): | |
stationsChanged = Signal() | |
def __init__(self): | |
QObject.__init__(self) | |
self.m_stations =[] | |
@Property('QVariantList', notify=stationsChanged) | |
def stations(self): | |
return self.m_stations | |
@stations.setter | |
def set_stations(self, val): | |
if self.m_stations == val: | |
return | |
self.m_stations = val[:] | |
self.stationsChanged.emit() | |
def list_fill(self): | |
self.stations = my_list | |
if __name__ == "__main__": | |
os.environ["QT_QUICK_CONTROLS_STYLE"] = "Material" | |
app = QApplication(sys.argv) | |
engine = QQmlApplicationEngine() | |
manager = Manager() | |
ctx = engine.rootContext() | |
ctx.setContextProperty("Manager", manager) | |
engine.load('main.qml') | |
if not engine.rootObjects(): | |
sys.exit(-1) | |
manager.list_fill() | |
sys.exit(app.exec_()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.10 | |
import QtQuick.Controls 2.1 | |
import QtQuick.Window 2.2 | |
import QtQuick.Controls.Material 2.3 | |
ApplicationWindow { | |
id: applicationWindow | |
Material.theme: Material.Light | |
title: qsTr("Test Invoke") | |
visible: true | |
width: 600 | |
height: 500 | |
ComboBox { | |
id: comboBox | |
width: 200 | |
model: Manager.stations | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment