久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='mctzB'></tfoot>

    • <bdo id='mctzB'></bdo><ul id='mctzB'></ul>

  1. <legend id='mctzB'><style id='mctzB'><dir id='mctzB'><q id='mctzB'></q></dir></style></legend>

      <small id='mctzB'></small><noframes id='mctzB'>

      <i id='mctzB'><tr id='mctzB'><dt id='mctzB'><q id='mctzB'><span id='mctzB'><b id='mctzB'><form id='mctzB'><ins id='mctzB'></ins><ul id='mctzB'></ul><sub id='mctzB'></sub></form><legend id='mctzB'></legend><bdo id='mctzB'><pre id='mctzB'><center id='mctzB'></center></pre></bdo></b><th id='mctzB'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='mctzB'><tfoot id='mctzB'></tfoot><dl id='mctzB'><fieldset id='mctzB'></fieldset></dl></div>

    1. 為什么我的 QFileSystemModel QModelIndex 無法獲取子節

      Why my QFileSystemModel QModelIndex couldn#39;t get child node infomation?(為什么我的 QFileSystemModel QModelIndex 無法獲取子節點信息?)

        <tbody id='KxeHf'></tbody>

      1. <small id='KxeHf'></small><noframes id='KxeHf'>

        <legend id='KxeHf'><style id='KxeHf'><dir id='KxeHf'><q id='KxeHf'></q></dir></style></legend>

            <bdo id='KxeHf'></bdo><ul id='KxeHf'></ul>
            <i id='KxeHf'><tr id='KxeHf'><dt id='KxeHf'><q id='KxeHf'><span id='KxeHf'><b id='KxeHf'><form id='KxeHf'><ins id='KxeHf'></ins><ul id='KxeHf'></ul><sub id='KxeHf'></sub></form><legend id='KxeHf'></legend><bdo id='KxeHf'><pre id='KxeHf'><center id='KxeHf'></center></pre></bdo></b><th id='KxeHf'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='KxeHf'><tfoot id='KxeHf'></tfoot><dl id='KxeHf'><fieldset id='KxeHf'></fieldset></dl></div>
            • <tfoot id='KxeHf'></tfoot>
              • 本文介紹了為什么我的 QFileSystemModel QModelIndex 無法獲取子節點信息?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在學習 pyqt 中的模型/視圖架構,但是當我遵循 ,2) 指出:

                <塊引用>

                緩存和性能

                QFileSystemModel 不會獲取任何文件或目錄,直到調用 setRootPath().這將防止在此之前對文件系統進行的任何不必要的查詢,例如列出 Windows 上的驅動器.

                與 QDirModel 不同,QFileSystemModel 使用單獨的線程來填充本身所以它不會導致主線程作為文件系統掛起正在被查詢.調用 rowCount() 將返回 0,直到模型填充目錄.

                QFileSystemModel 保存一個包含文件信息的緩存.緩存是使用 QFileSystemWatcher 自動保持最新.

                <小時><塊引用>

                QModelIndex QFileSystemModel::setRootPath(const QString &newPath)

                集合模型正在監視的目錄到 newPath 通過在其上安裝文件系統觀察程序.對文件的任何更改和此目錄中的目錄將反映在模型中.

                如果路徑改變,將發出 rootPathChanged() 信號.

                注意:此功能不會改變模型的結構或修改視圖可用的數據.換言之,根"模型未更改為僅包含文件和目錄文件系統中newPath指定的目錄.

                強調我的

                加載過程在不同的線程中執行,并且加載是異步完成的,因此在您發出請求時,模型尚未加載.

                解決方案:

                解決方案是在加載后請求信息,該信息將通過 的 noreferrer">directoryLoaded 信號QFileSystemModel:

                from PyQt5.QtCore import pyqtSlot, QDir從 PyQt5.QtWidgets 導入 QApplication、QFileSystemModel、QPushButton類 DemoB(QPushButton):def __init__(self, parent=None):super().__init__(父)self.clicked.connect(self.on_clicked)self.model = QFileSystemModel(self)self.model.directoryLoaded.connect(self.on_directoryLoaded)@pyqtSlot()def on_clicked(self):self.model.setRootPath(QDir.homePath())@pyqtSlot(str)def on_directoryLoaded(自我,目錄):parentIndex = self.model.index(目錄)對于范圍內的行(self.model.rowCount(parentIndex)):index = self.model.index(row, 0, parentIndex)打印(索引,index.data())如果 __name__ == "__main__":導入系統應用程序 = QApplication(sys.argv)w = DemoB()w.show()sys.exit(app.exec_())

                I am learn about Model/View architecture in pyqt, but when i follow the Using model indexes instruction and try to write a demo in pyqt5 style.The QModelIndex couldn't get child node information?

                The code:

                class DemoB(QPushButton):
                    def __init__(self):
                        super().__init__()
                
                        self.clicked.connect(self.on_clicked)
                
                    def on_clicked(self, checked):
                        model = QFileSystemModel()
                        model.setRootPath(QDir.homePath())
                        parentIndex = model.index(QDir.homePath())
                        print(parentIndex.data() )
                        print(parentIndex, model.rowCount(parentIndex), QDir.homePath())
                        for row in range(model.rowCount(parentIndex)):
                            index = model.index(row, 0, parentIndex)
                            print(index, index.data())
                

                The result:

                My folder:

                解決方案

                Explanation:

                As the docs(1, 2) points out:

                Caching and Performance

                QFileSystemModel will not fetch any files or directories until setRootPath() is called. This will prevent any unnecessary querying on the file system until that point such as listing the drives on Windows.

                Unlike QDirModel, QFileSystemModel uses a separate thread to populate itself so it will not cause the main thread to hang as the file system is being queried. Calls to rowCount() will return 0 until the model populates a directory.

                QFileSystemModel keeps a cache with file information. The cache is automatically kept up to date using the QFileSystemWatcher.


                QModelIndex QFileSystemModel::setRootPath(const QString &newPath)

                Sets the directory that is being watched by the model to newPath by installing a file system watcher on it. Any changes to files and directories within this directory will be reflected in the model.

                If the path is changed, the rootPathChanged() signal will be emitted.

                Note: This function does not change the structure of the model or modify the data available to views. In other words, the "root" of the model is not changed to include only files and directories within the directory specified by newPath in the file system.

                emphasis mine

                The loading process is executed in a different thread and the loading is done asynchronously, so at the time you make the request the model is not yet loaded.

                Solution:

                The solution is to request the information after it has been loaded that will be notified through the directoryLoaded signal of QFileSystemModel:

                from PyQt5.QtCore import pyqtSlot, QDir
                from PyQt5.QtWidgets import QApplication, QFileSystemModel, QPushButton
                
                
                class DemoB(QPushButton):
                    def __init__(self, parent=None):
                        super().__init__(parent)
                        self.clicked.connect(self.on_clicked)
                        self.model = QFileSystemModel(self)
                        self.model.directoryLoaded.connect(self.on_directoryLoaded)
                
                    @pyqtSlot()
                    def on_clicked(self):
                        self.model.setRootPath(QDir.homePath())
                
                    @pyqtSlot(str)
                    def on_directoryLoaded(self, directory):
                        parentIndex = self.model.index(directory)
                        for row in range(self.model.rowCount(parentIndex)):
                            index = self.model.index(row, 0, parentIndex)
                            print(index, index.data())
                
                
                if __name__ == "__main__":
                    import sys
                
                    app = QApplication(sys.argv)
                    w = DemoB()
                    w.show()
                    sys.exit(app.exec_())
                

                這篇關于為什么我的 QFileSystemModel QModelIndex 無法獲取子節點信息?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                How to bind a function to an Action from Qt menubar?(如何將函數綁定到 Qt 菜單欄中的操作?)
                PyQt progress jumps to 100% after it starts(PyQt 啟動后進度躍升至 100%)
                How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標簽設置在固定位置,以便當我向左或向右滾動時,yaxis 刻度標簽應該可見
                `QImage` constructor has unknown keyword `data`(`QImage` 構造函數有未知關鍵字 `data`)
                Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)

                        <tbody id='JqXgq'></tbody>
                    1. <i id='JqXgq'><tr id='JqXgq'><dt id='JqXgq'><q id='JqXgq'><span id='JqXgq'><b id='JqXgq'><form id='JqXgq'><ins id='JqXgq'></ins><ul id='JqXgq'></ul><sub id='JqXgq'></sub></form><legend id='JqXgq'></legend><bdo id='JqXgq'><pre id='JqXgq'><center id='JqXgq'></center></pre></bdo></b><th id='JqXgq'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='JqXgq'><tfoot id='JqXgq'></tfoot><dl id='JqXgq'><fieldset id='JqXgq'></fieldset></dl></div>
                      <tfoot id='JqXgq'></tfoot>

                    2. <small id='JqXgq'></small><noframes id='JqXgq'>

                        <legend id='JqXgq'><style id='JqXgq'><dir id='JqXgq'><q id='JqXgq'></q></dir></style></legend>

                          <bdo id='JqXgq'></bdo><ul id='JqXgq'></ul>
                          主站蜘蛛池模板: 亚洲欧美日韩国产 | 国模精品视频一区二区 | 日本一级淫片色费放 | 一区在线观看视频 | 国产美女自拍视频 | 双性呜呜宫交受不住了h | 成人免费黄色片 | 国产福利小视频 | 国产精品suv一区二区 | 91成人在线视频 | 成人在线观看视频网站 | 91av视频| 国产欧美综合一区二区三区 | 自拍偷拍中文字幕 | 黄色一级在线观看 | 女人av在线 | 人人草人人 | 国产黄色在线播放 | 国产成人在线视频 | 国产精品一二三四区 | www.国产精品 | av资源在线| 国产一区二区三区视频 | 亚洲福利一区 | 久久久久久网 | 欧美午夜理伦三级在线观看 | 一级黄色大片 | 国产成人精| 91色交视频| 国产色视频一区二区三区qq号 | 婷婷狠狠爱 | 成人激情视频在线观看 | 国产精品久久久一区二区三区 | 国产三级一区 | 成人特级毛片 | www.中文字幕| 91视频免费在线观看 | 国产欧美一区二区精品忘忧草 | 91久色 | 亚洲欧美日韩在线 | 99re这里只有精品6 |