Skip to content

Qt for Python

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

3.3k Topics 14.6k Posts
  • PyQt6 QCheckBox, different action when text/box is clicked.

    Unsolved
    3
    0 Votes
    3 Posts
    483 Views
    JonBJ
    @spinbean said in PyQt6 QCheckBox, different action when text/box is clicked.: I am trying to make a QCheckbox where I seperate between clicking on the checkbox "text" and the checkbox "box". I think you will find you should not do this. For consistent interface end users will expect clicking either will have same behaviour (checkbox state toggle), that is how 99% of applications work.
  • QMediaPlayer - Stopping on last frame

    Unsolved pyside python
    5
    0 Votes
    5 Posts
    1k Views
    J
    @SGaist Sure https://bugreports.qt.io/browse/QTBUG-118501
  • Tab resizing issues

    Unsolved
    8
    0 Votes
    8 Posts
    1k Views
    E
    @JonB I found on StackOverflow someone bringing up the same issue. It was 8 years old so I needed to bring it up to PySide6. It does indeed show the same problem, one tab needing to be large forcing the smaller tab to grow, needlessly to the same size. There is an answer which looks like it might work but I could not see how to implement it. In the code I've commented out code corresponding to the answer. #!/bin/python import sys from PySide6 import QtGui, QtCore, QtWidgets from PySide6.QtWidgets import (QApplication, QMainWindow, QTableWidget, QTableWidgetItem, QVBoxLayout, QWidget, QTabWidget, QLayout, QSizePolicy) class TabExample(QtWidgets.QWidget): def __init__(self): super(TabExample, self).__init__() self.initUI() def initUI(self): self.vbox_main = QtWidgets.QVBoxLayout() self.table_blank = QtWidgets.QTableWidget(10, 4) self.tabw = QtWidgets.QTabWidget() self.tab_A = QtWidgets.QWidget() self.vbox_A = QtWidgets.QVBoxLayout(self.tab_A) for i in range(40): lab = QtWidgets.QLabel('label %d' %i) self.vbox_A.addWidget(lab) self.tab_B = QtWidgets.QWidget() self.vbox_B = QtWidgets.QVBoxLayout(self.tab_B) for i in range(5): lab = QtWidgets.QLabel('labelB %d'%i) self.vbox_B.addWidget(lab) #COMMENT OUT NEXT LINE TO SEE DESIRED SIZE OF TAB B self.tabw.addTab(self.tab_A, 'Tab A') self.tabw.addTab(self.tab_B, 'Tab B') self.vbox_main.addWidget(self.table_blank, 1) self.vbox_main.addWidget(self.tabw) self.setLayout(self.vbox_main) self.setGeometry(0,0, 400, 600) #self.move(QtGui.QDesktopWidget().availableGeometry().center() - self.frameGeometry().center()) self.show() # def __init__(self): # super(TabExample, self).__init__() # self.initUI() # #self.tabWidget_2.currentChanged.connect(self.updateSizes) # #self.tab_B.parentWidget().connect(lab,800,600) # # self.tab_B.currentChanged.connect(self.updateSizes) # def updateSizes(self): # for i in range(self.tabWidget_2.count()): # #self.tabWidget_2.widget(i).setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) # self.tab_B.widget(i).setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) # # #current = self.tabWidget_2.currentWidget() # current = self.tab_B.currentWidget() # current.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) def main(): app = QtWidgets.QApplication(sys.argv) tabExample = TabExample() sys.exit(app.exec()) if __name__ == "__main__": main()
  • Why is the Qt Plugin sqldriver 'libqsqlpsql.dylib' looking for Postgres v14?

    Unsolved
    6
    0 Votes
    6 Posts
    673 Views
    SGaistS
    @Pipper you're welcome ! If that answers your question, please mark the thread as solved using the "Topic Tools" button or the three dotted menu beside the answer your deem correct so other forum users may know a solution has been found :-)
  • Partial Page Rendering with QtPDF

    Unsolved
    1
    0 Votes
    1 Posts
    240 Views
    No one has replied
  • 0 Votes
    8 Posts
    648 Views
    F
    If this is 6.6; it might be a manifestation of https://bugreports.qt.io/browse/QTBUG-118317 .
  • PyQT program crashes on Mac (not on Windows) when clicking on QComboBox

    Unsolved
    6
    0 Votes
    6 Posts
    1k Views
    jsulmJ
    @guillermollopis said in PyQT program crashes on Mac (not on Windows) when clicking on QComboBox: Also, I just get the error when using Mac, not Windows Well, it can work on one platform but fail on another. Can you provide a minimal reproducible example showing this behaviour? I could try on my Mac.
  • New to pyQT, threading question

    Unsolved
    2
    0 Votes
    2 Posts
    382 Views
    jsulmJ
    @jdev8000 You can move all this long lasting checks including the timer in a worker object which is running in another thread. Everytime there is something new in that thread the worker object emits a signal. This signal is connected to a slot in the UI thread. This slots updates the UI. Never touch UI in other threads, only in main/UI thread! See https://wiki.qt.io/QThreads_general_usage
  • Please Help

    Unsolved
    4
    0 Votes
    4 Posts
    321 Views
    SGaistS
    The most simple would be to do that on your own machine using a virtual environment. You can use either conda or pip's virtualenv. You also might want to move to PySide6.
  • Way to save QTextEdit scroll state?

    Moved Solved
    10
    0 Votes
    10 Posts
    1k Views
    JonBJ
    @Rivridis Anything "visual" like scroll position, size, cursor position, focus you need to leave it to draw itself once after e.g. setHtml(), because they get reset or need recalculating.
  • Flags: object cannot be interpreted as an integer

    Solved
    6
    0 Votes
    6 Posts
    1k Views
    JonBJ
    @sophia73583 said in Flags: object cannot be interpreted as an integer: Using and instead of & fixed my issue. Might have been issue with a later version of PySide. It might have fixed the error but I am surprised/you seem lucky it gives you the correct behaviour. In Python & is bit-wise AND, which ought be wanted here, while the and you are now using is logical True/False result.
  • pyqt6: Set CSS - I need help

    Unsolved
    3
    0 Votes
    3 Posts
    640 Views
    P
    Hello, At first I thought I had a problem with the menu. Now I've come to the conclusion that it's the CSS. There are no error messages at the moment, but here is debug information as requested: app_css = {str} 'QPushButton:focus { background-color: yellow } QTextEdit:focus { background-color: yellow } QComboBox:focus { background-color: yellow } QMainWindow {background-color: black; color: white;}' font_size = {str} '30' high_contrast = {bool} True self = {HTMLGeneratorApp} <main.HTMLGeneratorApp object at 0x0000026E98A09EA0> style = {str} 'font-size: 30px;'
  • Unable to remove empty ListWidgetItem

    Solved
    2
    0 Votes
    2 Posts
    268 Views
    JonBJ
    @sophia73583 item.deleted.connect(self.removeItem(item)) This is not the right way to connect a slot to pass it a parameter, and does not do what you think. You need: item.deleted.connect(lambda: self.removeItem(item))
  • Change colors in menuBar()

    Unsolved
    10
    0 Votes
    10 Posts
    1k Views
    P
    this code: if high_contrast: style += " QMainWindow {background-color: black; color: white;}" print(style) self.main_window.setStyleSheet(style) output print: font-size: 30px; QMainWindow {background-color: black; color: white;} but this works: if high_contrast: style = " QMainWindow {background-color: black; color: white;}" print(style) self.main_window.setStyleSheet(style) output print: QMainWindow {background-color: black; color: white;} the problem just appears with += . (style += )
  • pyside6-deploy.py without QML - how?

    Solved
    7
    0 Votes
    7 Posts
    2k Views
    S
    @Shyamnath thanks once again for your answer. I confirm that you were right about the reason - everything went well when I moved venv into different location. (Unfortunately the whole thing became broken after recent updates. A binary file created by pure nuitka worked month ago. But today nothing happens if I run newly generated file - regardles who created it - nuitka or pyside6-deploy. It exits silently without any error message).
  • QTextEdit()Add lookup list

    Unsolved
    6
    0 Votes
    6 Posts
    466 Views
    ewerybodyE
    Have you had a look at the pyQode project? https://github.com/pyQode/pyqode.core I can't point you to the exact point now. But surely this is done with pyQode!
  • Python Qt6 - change font size at runtime

    Unsolved
    2
    0 Votes
    2 Posts
    283 Views
    P
    I figured it out: def change_font_size(self, new_font_size): """ Ändert die Schriftgröße im QMainWindow """ fontsize = new_font_size self.setStyleSheet('font-size: ' + fontsize+'px')
  • How to resize images so they always fit to the scene ?

    Unsolved
    3
    0 Votes
    3 Posts
    5k Views
    JoeCFDJ
    @Mattik if you have svg images, you use QGraphicsSvgItem because QGraphicsPixmapItem can not preserve the resolution of the images.
  • This topic is deleted!

    Solved
    1
    0 Votes
    1 Posts
    12 Views
    No one has replied
  • Data Science Challenge: Analyzing Customer Purchase Patterns

    Unsolved
    3
    0 Votes
    3 Posts
    343 Views
    JonBJ
    @Sachin-Bhatt said in Data Science Challenge: Analyzing Customer Purchase Patterns: Could you provide Python code examples and explanations for each of these analyses using the provided dataset? Since this is a Python question, nothing to do with Qt, I suggest you ask in a Python forum. Also, I hate to ask, but is the point of this "challenge" that you figure the stuff for yourself rather than asking others to give the answer?