Code Monkey home page Code Monkey logo

exdir-browser's People

Contributors

auroramoen avatar dragly avatar lepmik avatar miladh avatar simetenn avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

exdir-browser's Issues

Wrong model is attached to index

This is an upstream bug in PyQt. Reported here as a reminder to fix all calls to treeView.__model.expand() when it is fixed.

Whenever we request an index from the model or get one back in the onClicked calls, it holds the wrong model internally. This causes any calls to expand or collapse to fail due to a index.model !== model check. We can work around this by calling expand on the TreeView modelAdaptor, which is accessible through the __model property.

Here is a sample code that reproduces the issue:

import ctypes
from ctypes.util import find_library

# OpenGL fix (must be set before other imports)
libGL = find_library("GL")
ctypes.CDLL(libGL, ctypes.RTLD_GLOBAL)

from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtQml import *
import sys

class TreeModel(QAbstractItemModel):
    def index(self, row, column, parent):
        return self.createIndex(row, column, 0)

if __name__ == "__main__":
    qmlRegisterType(TreeModel, "TreeModel", 1, 0, "TreeModel")

    app = QApplication(sys.argv)

    engine = QQmlApplicationEngine()
    component = QQmlComponent(engine)
    component.setData(b"""
import QtQuick 2.4
import QtQuick.Controls 1.4
import TreeModel 1.0

ApplicationWindow {
    width: 1280
    height: 900
    visible: true
    
    TreeModel {
        id: treeModel
        Component.onCompleted: {
            var i = index(0, 0, 0)
            console.log("Index model", i.model)
            console.log("Real model", treeModel)
        }
    }
}
""", QUrl("test"))
    window = component.create()
    window.show()
    # engine.load(QUrl("qml/main.qml"))

    app.exec_()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.