Skip to content
  • QAbstractListModel setHeaderData

    Unsolved Qt for Python
    3
    0 Votes
    3 Posts
    682 Views
    A

    @JonB Thanks for your reply,
    My question is if i don't need to implement setHeaderData() and my code shouldn't call it, How to make ListView{} call it and set displayed data with header's text (i attached picture for code of main.qml).

    edd9ba30-5acf-4cd2-8f46-c20e869c5548-image.png

  • 0 Votes
    5 Posts
    965 Views
    K

    @SGaist I don't know how to call it before, now I found using super().paintEvent(arg__1) can solve it.

  • Organizing Pyside2 Code

    Solved Qt for Python
    2
    0 Votes
    2 Posts
    405 Views
    Volodymyr14V

    Need to organize main.qml file that imports nested files of subdirectories. If you have in main.qml:
    import "qmlFiles" as Uqmls
    then inside qmlFiles/ directory you have some.qml file and qmlDir, then there inside this file:
    import "qmlDir" as UDir
    Is better to organize by this way:

    dir/ of your main.qml file. dir/subdir/ for import from main.qml file dir/subdir/subdir/ for import from files that are in the dir/subdir/
  • 0 Votes
    8 Posts
    1k Views
    D

    @eyllanesc I feel quite dumb. Changing MouseArea.onClicked to onClicked fixed the problem. Thanks for the help to everyone who replied.

  • PySide2 index of setData

    Unsolved Qt for Python
    4
    0 Votes
    4 Posts
    813 Views
    JonBJ

    @Abdulrahman
    Not my area, perhaps this question should be posted to the QML sub-forum, if you don't get an answer here in a while? (except to say: if you have the row, column & model, model->index(row, column) delivers the QModelIndex, if that helps from QML.)

  • 0 Votes
    22 Posts
    39k Views
    SGaistS

    Looks like you installed all your stuff in the base conda environment which is a bad idea.

    I would recommend re-install conda cleanly and create a proper environment to install PySide2.

  • 0 Votes
    2 Posts
    231 Views
    W

    sorry miss part of my code please ignore

  • 0 Votes
    13 Posts
    1k Views
    M

    if you do this work,please also shared with me. I also need this

  • 0 Votes
    4 Posts
    2k Views
    JonBJ

    @Tony32423 said in How to tell Qt/PySide2 where to look for the qt.conf file on Windows?:

    Usually this is fine as qt.conf is in the same folder as python.exe

    I'm sorry I'm not providing any solution here, but this sounds awful! Why would a Qt configuration file be placed in the same directory of the general python.exe program?

    Something similar happens with PyQt5 in that it doesn't pick up the qt.conf file from the arguments, but it does at least default the locations to its own copy of the qt libs in its site-packages folder.

    This sounds much better. The qt.conf file should surely be placed somewhere inside Qt stuff.

  • 0 Votes
    10 Posts
    946 Views
    SGaistS

    I highly encourage you to learn the signals and slots paradigm.

    Qt is an asynchronous framework which means that you may not need an additional thread depending on what you need to process and how you process it.

    Did they warm you about the nuclear footgun that it can be ? ;-)

  • 0 Votes
    16 Posts
    1k Views
    JonBJ

    @andre_sophia
    Glad it solved. Yes, in the normal course do all your connect()s in the __init__(), after the setupUi(), so it's just once.

  • 0 Votes
    7 Posts
    1k Views
    B

    I installed it using pip
    pip install pyside2

    I'm on windows using python 3.7

  • 0 Votes
    3 Posts
    1k Views
    M

    Thank you for your reply. I have tried setting blockSignals(True) on both the data model and the tree view before clearing rows (experimentally, with the understanding that it's not a great thing to do), and I see no difference. Also tried model.beginResetModel() and endResetModel() around the clear() method, and no difference there either.

    I have also tried this amalgamation just to try to dig into the problem:

    self.model_dailies.blockSignals(True) self.tree_alldailies.blockSignals(True) for row in range(self.model_dailies.rowCount()): print("Removing", row) self.model_dailies.removeRow(row) self.tree_alldailies.blockSignals(False) self.model_dailies.blockSignals(False)

    From the print statement there, I can see that it starts out pretty quickly (removing approx 100 rows/second) then around 400-500 rows in, it slows down gradually to about 1 per second for the next ~500, and then fluctuates from there. This is true for any data that is being loaded/unloaded.

    What really gets me is that I'm re-writing this program from a version I wrote with tkinter, and in the tkinter program, switching between the exact same data sets in the treeview is instantaneous even with the REST call.

    I am admittedly very new to PySide2 and I'm sure I have much to learn (like implementing my own model from QAbstractItemModel), but I don't understand why merely adding text rows of data with Qt's own built-in QStandardItemModel yields such terrible performance!

  • 0 Votes
    2 Posts
    442 Views
    SGaistS

    Hi and welcome to devnet,

    On macOS 10.13.6, I have the situation in the other direction. The selection does not follow at all when changing the month.

    I saw there were patches going in for the model used by this widget so I wonder if this behaviour will change.

  • 0 Votes
    7 Posts
    1k Views
    Z

    @Pablo-J-Rogina @SGaist
    I checked the C++ code and i found that the WebSocketServer Class in C++ has a "setsslconfiguration" function while the Python doesn't have.If i construct a SSL certification like this:

    cacert_key = QFile('cacert.pem') priv_key = QFile('privkey.pem') server_config = QSslConfiguration() server_config.setLocalCertificate(cacert_key) server_config.setPrivateKey(priv_key)

    but i don't know how to implement this to the WebScoketServer i build.

  • 0 Votes
    15 Posts
    2k Views
    D

    @SGaist I'll pull something together. You will need blender 2.83+ however to test it.

  • QT designer и python

    Unsolved Qt for Python
    15
    0 Votes
    15 Posts
    1k Views
    jsulmJ

    @VOLFRAMHERO Did you add

    self.pushButton.clicked.connect(self.shift)

    to setupUi? Also, you should remove that line from shift().

  • 0 Votes
    2 Posts
    466 Views
    D

    Someone has answered this on StackOverflow.

  • Help with Gif

    Unsolved Qt for Python
    2
    0 Votes
    2 Posts
    841 Views
    D

    If you use PyQt you can use QMovie to play (animated) gifs.
    Like this:

    from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtGui import QMovie import sys class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(250, 250) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") # create label self.label = QtWidgets.QLabel(self.centralwidget) self.label.setGeometry(QtCore.QRect(25, 25, 200, 200)) self.label.setMinimumSize(QtCore.QSize(200, 200)) self.label.setMaximumSize(QtCore.QSize(200, 200)) self.label.setObjectName("label") # add label to main window MainWindow.setCentralWidget(self.centralwidget) # set qmovie as label self.movie = QMovie("earth.gif") self.label.setMovie(self.movie) self.movie.start() if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) window = QtWidgets.QMainWindow() ui = Ui_MainWindow() ui.setupUi(window) window.show() sys.exit(app.exec_())

    source: https://pythonpyqt.com/pyqt-gif/