Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PySide2/QtWidgets problem in setStandardButtons
QtWS25 Last Chance

PySide2/QtWidgets problem in setStandardButtons

Scheduled Pinned Locked Moved Unsolved Qt for Python
pyside2
2 Posts 2 Posters 782 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    ZEZON
    wrote on last edited by
    #1

    Thats te code I used to create a message box with just yes and no options
    cd063fe5-312a-4774-8063-69a9b9918d3c-image.png
    But I'm getting this error
    TypeError: 'PySide2.QtWidgets.QMessageBox.StandardButton' object cannot be interpreted as an integer

    But if I put njust one button, it works
    a6929fa3-4f91-48c3-8e43-20c6692e5c99-image.png
    5ce94bd4-7542-49cf-b3f8-a5659f73dc73-image.png
    I'm using QMessageBox from PySide2.QtWidgets

    JonBJ 1 Reply Last reply
    0
    • Z ZEZON

      Thats te code I used to create a message box with just yes and no options
      cd063fe5-312a-4774-8063-69a9b9918d3c-image.png
      But I'm getting this error
      TypeError: 'PySide2.QtWidgets.QMessageBox.StandardButton' object cannot be interpreted as an integer

      But if I put njust one button, it works
      a6929fa3-4f91-48c3-8e43-20c6692e5c99-image.png
      5ce94bd4-7542-49cf-b3f8-a5659f73dc73-image.png
      I'm using QMessageBox from PySide2.QtWidgets

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @ZEZON
      Please paste code not screenshots so people can copy from it.

      Your code should be working, but I'm afraid it looks like it isn't due to some PySide2->Python issue. https://www.pythonguis.com/tutorials/pyside-dialogs/ for PySide2 even includes same line as you. If you can test under PyQt5 that would confirm.

      I don't suppose it will help, but try:

      buttons = QMessageBox.Yes | QMessageBox.No
      mais.setStandardButtons(buttons)
      

      Actually, if you try the above one and it errors please show which of the two lines it complains about, that would be useful to know.

      I don't know whether something like

      buttons = QMessageBox.StandardButton(QMessageBox.Yes | QMessageBox.No)
      mais.setStandardButtons(buttons)
      

      would work.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved