FrontPage / Python / PySideその2

http://personals-index.com/index1552.html http://personals-index.com/index1553.html http://personals-index.com/index1554.html http://personals-index.com/index1555.html http://personals-index.com/index1556.html http://personals-index.com/index1557.html http://personals-index.com/index1558.html http://personals-index.com/index1559.html http://personals-index.com/index1560.html http://personals-index.com/index1561.html http://personals-index.com/index1562.html http://personals-index.com/index1563.html http://personals-index.com/index1564.html http://personals-index.com/index1565.html http://personals-index.com/index1566.html http://personals-index.com/index1567.html http://personals-index.com/index1568.html http://personals-index.com/index1569.html http://personals-index.com/index1570.html http://personals-index.com/index1571.html http://personals-index.com/index1572.html http://personals-index.com/index1573.html http://personals-index.com/index1574.html http://personals-index.com/index1575.html http://personals-index.com/index1576.html http://personals-index.com/index1577.html http://personals-index.com/index1578.html http://personals-index.com/index1579.html http://personals-index.com/index1580.html http://personals-index.com/index1581.html http://personals-index.com/index1582.html http://personals-index.com/index1583.html http://personals-index.com/index1584.html http://personals-index.com/index1585.html http://personals-index.com/index1586.html http://personals-index.com/index1587.html http://personals-index.com/index1588.html http://personals-index.com/index1589.html http://personals-index.com/index1590.html http://personals-index.com/index1591.html http://personals-index.com/index1592.html http://personals-index.com/index1593.html http://personals-index.com/index1594.html http://personals-index.com/index1595.html http://personals-index.com/index1596.html http://personals-index.com/index1597.html http://personals-index.com/index1598.html http://personals-index.com/index1599.html http://personals-index.com/index1500.html http://personals-index.com/index1501.html http://personals-index.com/index1502.html http://personals-index.com/index1503.html http://personals-index.com/index1504.html http://personals-index.com/index1505.html http://personals-index.com/index1506.html http://personals-index.com/index1507.html http://personals-index.com/index1508.html http://personals-index.com/index1509.html http://personals-index.com/index1510.html http://personals-index.com/index1511.html http://personals-index.com/index1512.html http://personals-index.com/index1513.html http://personals-index.com/index1514.html http://personals-index.com/index1515.html http://personals-index.com/index1516.html http://personals-index.com/index1517.html http://personals-index.com/index1518.html http://personals-index.com/index1518.html http://personals-index.com/index1518.html http://personals-index.com/index1521.html http://personals-index.com/index1522.html http://personals-index.com/index1523.html http://personals-index.com/index1524.html http://personals-index.com/index1525.html http://personals-index.com/index1526.html http://personals-index.com/index1527.html http://personals-index.com/index1528.html http://personals-index.com/index1529.html http://personals-index.com/index1530.html http://personals-index.com/index1531.html http://personals-index.com/index1532.html http://personals-index.com/index1533.html http://personals-index.com/index1534.html http://personals-index.com/index1535.html http://personals-index.com/index1536.html http://personals-index.com/index1537.html http://personals-index.com/index1538.html http://personals-index.com/index1539.html http://personals-index.com/index1540.html http://personals-index.com/index1541.html http://personals-index.com/index1542.html http://personals-index.com/index1543.html http://personals-index.com/index1544.html http://personals-index.com/index1545.html http://personals-index.com/index1546.html http://personals-index.com/index1547.html http://personals-index.com/index1548.html http://personals-index.com/index1549.html http://personals-index.com/index1552.html http://personals-index.com/index1551.html http://personals-index.com/index1550.html http://personals-index.com/index1652.html http://personals-index.com/index1653.html http://personals-index.com/index1654.html http://personals-index.com/index1655.html http://personals-index.com/index1656.html http://personals-index.com/index1657.html http://personals-index.com/index1658.html http://personals-index.com/index1659.html http://personals-index.com/index1660.html http://personals-index.com/index1661.html http://personals-index.com/index1662.html http://personals-index.com/index1663.html http://personals-index.com/index1664.html http://personals-index.com/index1665.html http://personals-index.com/index1666.html http://personals-index.com/index1667.html http://personals-index.com/index1668.html http://personals-index.com/index1669.html http://personals-index.com/index1670.html http://personals-index.com/index1671.html http://personals-index.com/index1672.html http://personals-index.com/index1673.html http://personals-index.com/index1674.html http://personals-index.com/index1675.html http://personals-index.com/index1676.html http://personals-index.com/index1677.html http://personals-index.com/index1678.html http://personals-index.com/index1679.html http://personals-index.com/index1680.html http://personals-index.com/index1681.html http://personals-index.com/index1682.html http://personals-index.com/index1683.html http://personals-index.com/index1684.html http://personals-index.com/index1685.html http://personals-index.com/index1686.html http://personals-index.com/index1687.html http://personals-index.com/index1688.html http://personals-index.com/index1689.html http://personals-index.com/index1690.html http://personals-index.com/index1691.html http://personals-index.com/index1692.html http://personals-index.com/index1693.html http://personals-index.com/index1694.html http://personals-index.com/index1695.html http://personals-index.com/index1696.html http://personals-index.com/index1697.html http://personals-index.com/index1698.html

FrontPage/Python/PySide

自動終了

       # デバッグ用) 自動終了
       self.timer = QTimer()
       self.timer.singleShot(20*1000, self.close)

QListView?の最速利用法

# :: FileListView
self.model = QStringListModel()
self.listView = QListView()
self.listView.setModel(self.model)
 self.model.setStringList(["abc", "def", "ghi", "jkl"])
self.listView.clicked.connect(self.flush_listitem)
   @Slot()
   def flush_listitem(self, index):
       sel1 = index.data(Qt.DisplayRole)
       sel2 = [i.data(Qt.DisplayRole) for i in self.listView.selectedIndexes()]
       print sel1
       print sel2

Qt CSS Style一覧

https://wiki.qt.io/Style-CSSBased

QObject.sender()

シグナルの発行元オブジェクトを取得したい場合 https://wiki.qt.io/PySide-Pitfalls-Japanese

(注意) sender()は@Slotを実装してるメソッド内でのみ動く

class Listener(QObject):
       @Slot()
       def on_signal(self,*args):
               print args
               print self.sender()
listner = Listener()
btn.someSignal.connect(listener.on_signal)

QtCore?.Property

プロパティのセッターにより,値が変更されると,シグナルを発行できる.

from PySide.QtCore import QObject, Property

class MyObject(QObject):
       def __init__(self, startval=42):
               QObject.__init__(self)
               self.ppval = startval
       def readPP(self):
               return self.ppval
       def setPP(self,val):
               self.ppval = val
       pp = Property(int, readPP, setPP)

       obj = MyObject()
       obj.pp = 47

タスクトレイアプリ

基本形 http://flame-blaze.net/archives/3094

Threadを使って実用的。ただコード動かない。 http://woodboy644.hatenablog.com/entry/2013/07/30/001910

qApp.quitの注意点。

self.connectでつながないと動かない

       # : Quitアクション作成
       self.quitAction = QAction("&Quit", self)
       self.connect(self.quitAction, SIGNAL('triggered()'), qApp, SLOT('quit()'))
       # self.quitAction.triggered.connect(qApp.quit)

画面サイズの保存

def __init__():
        # 設定を読み込む
       self.mySettings = QSettings("my company", "hoge Analyser") # レジストリ
      self.mySettings = QSettings("myMDIApp.ini", QSettings.IniFormat) # iniファイル
       self.restoreGeometry(self.mySettings.value("abc/geometry")) # QWidgetとQMainWIndow
       self.restoreState(self.mySettings.value("abc/windowState")) # QMainWindow
# ウインドウを閉じた時
def closeEvent(self, event):
       self.mySettings.setValue("abc/geometry", self.saveGeometry())
       self.mySettings.setValue("abc/windowState", self.saveState())
       # 終了処理
       qApp.quit()

QML式でのプロパティ

もし、QML式の中でオブジェクトのプロパティを使いたいなら、 そのプロパティはNOTIFYableでなくてはなりません。 (訳注:NOTIFYable=通知可能。ここではProperty関数のnotify引数が与えられている事) 以下は、シンプルなシグナルを使用する例です。

class Person(QtCore.QObject):
   def __init__(self, name):
       QtCore.QObject.__init__(self)
       self._person_name = name
 
   def _name(self):
       return self._person_name
    
   @QtCore.Signal 
   def name_changed(self): 
       pass
    
   name = QtCore.Property(unicode, _name, notify=name_changed)

更なる使い方

http://nullege.com/codes/search/PySide.QtCore.Property

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-05-26 (木) 12:17:12 (846d)