Skip to content

Qt for Python

For discussion and questions about Qt for Python (PySide & Shiboken)

3.3k Topics 14.6k Posts
  • Object oriented PyQt5 in Python not working

    Unsolved
    9
    0 Votes
    9 Posts
    1k Views
    SGaistS
    You are taking the problem on the wrong end. From a coding point of view, moving all the code that concerns one specific type of widgets in a different file does not make anything clearer. Keep each of your custom widgets in its own file so their code is in one coherent place.
  • 0 Votes
    4 Posts
    639 Views
    SGaistS
    @Ahmad_hikmat said in Hi please help with this issue knowing that I am using python 3.8.3 and that I am using pycharm and pyQt5 installed: I'm sorry I recently joined No problem, you can fix your original post by editing it. Can you show your code ?
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    6 Views
    No one has replied
  • How to get the text that is inserted in QPlainTextEdit?

    Solved
    3
    0 Votes
    3 Posts
    437 Views
    _
    @SGaist I'll take a look.
  • 0 Votes
    2 Posts
    1k Views
    C
    Did you ever find a fix? Mine is doing the exact same thing.
  • Populating a ListView with Python Objects

    Unsolved
    10
    0 Votes
    10 Posts
    3k Views
    L
    Old post but Google led me here so it seemed like a place to drop a super-simple solution. One approach that works very easily if you have a python list of QObject derived objects is to pass a QVariantList of QObjects and access them via @Property class MyItemModel(QObject): ... @Property(str) def name(self): return self.m_name class MyDataModel(QObject): ... @Property('QVariantList') def names(self): return list(self.m_item_objects_list) QML: LiistView { id: lv model: mydatamodelinstance.names // setContextProperty of a MyDataModel object delegate: { Text { text: modelData.name } } // This gets the name property of a MyItemModel }
  • Return a function if arrow up key pressed

    Unsolved
    2
    0 Votes
    2 Posts
    259 Views
    SGaistS
    Hi, Ui_MainWindow is not a QObject nor a QWidget. You should not modify it as it is generated code. You should implement your logic in MainWindow.
  • Clear QTableView Data

    Unsolved
    8
    0 Votes
    8 Posts
    4k Views
    JonBJ
    @hachbani Nothing in "1,500 rows" should take 30 seconds, let alone 5 minutes. I know that's a broad statement, but you know what i mean! 1,500 lines/nodes of XML is nothing, computers do that in their sleep :) The "adding row by row" potential-slowness is to do with the sorting proxy, as per the link I gave you. (Though like I said I'd be surprised if that had anything near 5 minute overhead.) You seem to be a reasonable programmer! So don't despair, the time should be east to track down. Find out where it is. For example, comment out adding the lines into the model, just time the XML parsing to start with. Then comment out placing a QSortFilterProxyModel on the source model. And so on. I cannot see why clearing out the model data or calling beginResetModel() would cause some great degradation in speed.
  • pyside6-lupdate not work file not found error

    Unsolved
    1
    0 Votes
    1 Posts
    572 Views
    No one has replied
  • Can`t make a design

    Unsolved
    11
    0 Votes
    11 Posts
    1k Views
    MagmaM
    @jsulm thanks 4 ur time ♥
  • Exit code -1073740791 (0xC0000409) when I input a string in QTextEdit

    Solved
    4
    0 Votes
    4 Posts
    8k Views
    Black CatB
    For the people with same problem try to replace the QTextEdit for a label + scroll area, it worked for me (Y)
  • characters like { } can't be written in a Qt Widget

    Unsolved
    4
    0 Votes
    4 Posts
    462 Views
    KroMignonK
    @iwrwrc said in characters like { } can't be written in a Qt Widget: But I needed to know as you said that most widgets don't do anything with character input. Because that what I found. Why do you not simply show your code? So we can see what you are trying and help you to resolve the issue.
  • QMessageBox hangs but doesn't show with exec()

    Unsolved
    7
    0 Votes
    7 Posts
    1k Views
    JonBJ
    @DoubleFelix I don't know what your code is. But (IMHO anyway) no other class should call any method in the main window class, nor have any access to it, nor import it. And I cannot see why the main window would want to export a method whose job is to show a message box. Further, that method ends by closing the main window, and it did not even open it. Start by redesigning some clean & logical flow. Why is some ClientWindow derived from QMainWindow? If you need this message box to be show, why can't the other place create and show it? Or, if for some reason it's necessary to have the main window show it, have the outside world emit a signal requesting it and have the main window slot onto that to show the dialog.
  • Is system modal dialog support in python pyqt-5/ubuntu.

    Unsolved
    15
    0 Votes
    15 Posts
    2k Views
    Y
    @JonB The browser process means chromium-browser.
  • Program Crashes ERROR when converting a numpy array to Pixmap

    Solved
    10
    0 Votes
    10 Posts
    2k Views
    D
    Okay, so it worked: I used the following function to create a QImage: def numpyQImage(image): qImg = QImage() if image.dtype == np.uint8: if len(image.shape) == 2: channels = 1 height, width = image.shape bytesPerLine = channels * width qImg = QImage( image.data, width, height, bytesPerLine, QImage.Format_Indexed8 ) qImg.setColorTable([qRgb(i, i, i) for i in range(256)]) elif len(image.shape) == 3: if image.shape[2] == 3: height, width, channels = image.shape bytesPerLine = channels * width qImg = QImage( image.data, width, height, bytesPerLine, QImage.Format_RGB888 ) elif image.shape[2] == 4: height, width, channels = image.shape bytesPerLine = channels * width fmt = QImage.Format_ARGB32 qImg = QImage( image.data, width, height, bytesPerLine, QImage.Format_ARGB32 ) return qImg After this, new = out.copy() image = numpyQImage(new) pixmap = QPixmap.fromImage(image) label.setPixmap(pixmap) vbox = QVBoxLayout() vbox.addWidget(label) win.setLayout(vbox) win.show() sys.exit(app.exec_()) @SGaist Thank you for your help!
  • Qlineedit: uneditable text + editable text

    Moved Solved
    7
    0 Votes
    7 Posts
    1k Views
    B
    I avoided the subclassing as it did not give me desired output went with simple approach closing ticket
  • How to limit the number of characters in QPlainTextEdit?

    Solved
    3
    1 Votes
    3 Posts
    2k Views
    JonBJ
    @_jao_victor_ Additional to @DoubleFelix's find, untested but I assume you could also limit the number characters by placing a suitable QValidator on the QPlainTextEdit. If that works, you shouldn't have to deal with key press events.
  • How to split project based on .pyproject file into sub modules?

    Unsolved pyside2 qt for python
    1
    0 Votes
    1 Posts
    371 Views
    No one has replied
  • Question about PlainTextEdit and TextEdit

    Unsolved
    2
    0 Votes
    2 Posts
    244 Views
    aha_1980A
    @Black-Cat my software crash and it return: please show your code. Regards
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied