Skip to content

Qt for Python

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

3.3k Topics 14.6k Posts
  • setRange(min, max) doesn't work for QDateTimeAxis. How to do it right?

    Solved
    2
    0 Votes
    2 Posts
    645 Views
    S
    Ah, ok, I found my mistake! Declaration of setRange() method: void setRange(QDateTime min, QDateTime max) shows that it takes QDateTime and not unix timestamp. I was confused because series take unix timestamps as date/time data and I expected here to be the same. It was my mistake, now it works with: axisX.setRange(QDateTime(QDate(2020, 3, 1)), QDateTime(QDate(2021, 9, 1)))
  • Python 4-channel rtsp(rtmp) streaming program QThread slow problem

    Unsolved
    11
    0 Votes
    11 Posts
    3k Views
    U
    @JonB When running 4 live streams with a single thread, the delay for each channel increased. Probably because of cv2.read 4 times in one thread I don't know if this is the correct coding.
  • How to throw error message when QPushbutton is clicked if LineEdit fields are empty

    Unsolved
    7
    0 Votes
    7 Posts
    1k Views
    JonBJ
    @LT-K101 said in How to throw error message when QPushbutton is clicked if LineEdit fields are empty: self.btnButton.setDisable(True) self.btnButton.setDisable(False) What happens when you run your code? There is no such method as QPushButton.setDisable(). There is setDisabled() or setEnabled(). disableButton() This is not the way to call a member function in Python.
  • QSqlDatabase, SQLite and Decimal (on python)

    qt for python
    7
    0 Votes
    7 Posts
    925 Views
    S
    @JonB said in QSqlDatabase, SQLite and Decimal (on python): By the time MySQL's decimal type hit Qt's model it gets converted to float, even though Python (not C++) has a decimal type Oh, thanks for mentioning this fact. I didn't know it and expected that Qt would be able to handle Decimal itself. This way it appears I'll need to do similar job and also modify QSqlQuery to handle data updates properly. I'll think about it. Thank you very much for information.
  • `TypeError: arguments did not match any overloaded call:`

    Unsolved
    6
    0 Votes
    6 Posts
    6k Views
    C
    @SGaist I'll read the docs next time. I had my suspicions but i also didnt think of the grid method. It works now, thanks eyllansc. I wasn't aware grid worked with scroll area. Thanks!
  • Using QPainter to paint into offscreen QPixmap fails

    Solved pyside qt for python
    4
    0 Votes
    4 Posts
    1k Views
    mrjjM
    @D-Drum Hi super :) I agree there could be some more info about this in the docs.
  • PyQt5 - Make all QScrollArea scrollable

    Solved
    7
    0 Votes
    7 Posts
    1k Views
    PatitotectiveP
    @eyllanesc Thanks, it worked.
  • No Qt platform plugin could be initialized

    Unsolved
    3
    0 Votes
    3 Posts
    2k Views
    I
    @JonB It was much simpler for me to get ride of conda and switch to pip and venv. Perhaps, it was a conda issue.
  • PySide6 disables logging debug level

    Unsolved
    5
    0 Votes
    5 Posts
    1k Views
    S
    @eyllanesc said in PySide6 disables logging debug level: I recommend you report it Just did. Thanks a lot.
  • Make sure 'QTextCursor' is registered using qRegisterMetaType()

    Unsolved
    5
    0 Votes
    5 Posts
    4k Views
    eyllanescE
    @Caeden It seems that you have not understood the usefulness or operation of the signals, I recommend you review the official docs. what is _message? If _message is a string then the slot must have the argument: foo_text = "Foo" self.text_changed.emit(foo_text) def settext(self, text): print(text)
  • PyQt5 - How to stop displaying shortcut in QAction?

    Unsolved
    11
    0 Votes
    11 Posts
    916 Views
    PatitotectiveP
    @JonB What i'm trying to do now is to create the shortcut independently of the QAction. But i also want to display the shortcut next to the QAction but it seems that QAction doesn't support html style (because it displays the html as text), i mean <span style="color: #ffffff; font-size: 14px;">Ctrl+Q</span>. So my question now is, there is a way to make QAction supports html style or another style way?
  • How do I make text invisible using PyQt5?

    Unsolved
    6
    0 Votes
    6 Posts
    2k Views
    JonBJ
    @_jao_victor_ As @jsulm has said. If you really do not want to reset the text to empty, you might instead set its foreground color to whatever the background color of the QLabel is, that should make the text invisible!
  • QPushButton vertical alignment in QToolBar

    Moved Unsolved
    8
    0 Votes
    8 Posts
    1k Views
    S
    I believe I figured out the "container widget" approach, which is just to instantiate each widget with a second argument pointing to an empty parent widget, then adding the parent widget to the toolbar. FWIW, I've attached screenshots of the results. It seems that — at least on my machine (macOS Catalina) — a subclass of QWidget still centers the button better than the container widget does. No idea why. [image: 7e8ae71f-82f3-4ee9-89bc-fea3276f07fe.png] @JoeCFD said in QPushButton vertical alignment in QToolBar: Try QToolButton which is made for QToolBar Thank you, I already have several QToolButtons in the toolbar but I really needed this one to stand out.
  • Assign to each QAction choice (on a Qmenu) a method

    Solved
    5
    0 Votes
    5 Posts
    377 Views
    JonBJ
    @john_hobbyist file.triggered[QAction].connect(self.calculate_1) file.triggered[QAction].connect(self.calculate_2) file.triggered[QAction].connect(self.calculate_3) This sets up so that any triggered action on file (your whole menu with all its actions) will call each/all of your slots. That is not what the code you chose to copy from did, it had one file.triggered[QAction].connect(self.processtrigger) Either do it that way, or more likely just connect each QAction to its slot. EDIT E.g. write calc_1.triggered.connect(self.calculate_1) instead of file.triggered[QAction].connect(self.calculate_1).
  • GUI not response when click button

    Moved Solved
    8
    0 Votes
    8 Posts
    439 Views
    eyllanescE
    @SeaLongHoang Neither QNetworkAccessManager nor python requests library are used to parse HTML, for this you must use Beautiful Soup library.
  • PyQt5 - QWidgetAction doesn't working when adding html style

    Solved
    8
    0 Votes
    8 Posts
    1k Views
    PatitotectiveP
    @Patitotective Fixed using: menu_stylesheet = ( "QMenu {" " background: #383838;" " color: #ABABAB;" " font-size: 15px;" "}" "QMenu::item:selected {" " background: #4C4C4C;" " color: #ffffff;" "}" "QMenu::item:pressed {" " background: #595959;" "}" )
  • Merge two pieces of code

    Moved Unsolved
    102
    0 Votes
    102 Posts
    43k Views
    SGaistS
    @john_hobbyist said in Merge two pieces of code: Do you see the problem? Bluntly speaking, your MyMplCanvas __init__ implementation is a mess. You are calling the init method of QLabel, do some stuff, then call the base class init implementation through super, set the parent independently, then you manage to use a method called imshow which is also a method from OpenCV's highgui module. You really should start by cleaning this up. Do things step by step. First question is: taking the rubber band part out of the equation for now, why do you need all these modifications on the MplCanvas class ? Are you sure you are using it correctly ?
  • Dynamic grid with pushbuttons

    Solved
    4
    1 Votes
    4 Posts
    546 Views
    JonBJ
    @Sebastian-Egger Yes, well done for adding the first parameter. I hadn't noticed that the QPushButton.clicked signal (e.g. https://doc.qt.io/qtforpython-5/PySide2/QtWidgets/QAbstractButton.html#PySide2.QtWidgets.PySide2.QtWidgets.QAbstractButton.clicked) passes checked as a parameter. Any extra named arguments must come after all unnamed arguments are specified, so if you need to add a named argument you need to pass any/all the existing, non-named arguments too.
  • QTableWidget print problem

    Solved
    4
    0 Votes
    4 Posts
    514 Views
    J
    @eyllanesc said in QTableWidget print problem: It seems that you are copying code without understanding it, I presume that in the original example QTextDocument was being used (or QTextEdit that has a QTextDocument) that does have the print_ method for it but that is the case of QWidget such as QTableWidget. Use render() method. yes, I looked here, but I couldn't find it, so I looked at external source examples, I knew it would not be suitable, but I wanted to do a trial and error method, the result did not surprise me either. meanwhile .render() worked but tablewidget is taking screenshot I guess I need to do more research and improve this code to make it work as I want. by the way thank you
  • Expanding Weirdness

    Solved
    5
    0 Votes
    5 Posts
    466 Views
    H
    @eyllanesc Thank you!