Home > Software design >  What is supported signatures and Union[]?
What is supported signatures and Union[]?

Time:11-24

If you wish to see base line questions skip problem details and see summary

Problem Details

I'm not too familiar with gui programming but I'm trying to get the smach_viewer to work for a project I'm working on for my class in ROS noetic. I've resorted to pulling all of the source code and putting it my workspace which already makes it more manageable but while adapting the code in one of the python packages I ran into an error I can't make heads or tails of:

  File "/home/hawk/final_project_ws/src/final-project-group-4-inc/src/xdot/xdot_qt.py", line 1914, in main
    app.setWindowIcon(QIcon(":/icon.png"))
TypeError: 'PySide6.QtGui.QGuiApplication.setWindowIcon' called with wrong argument types:
  PySide6.QtGui.QGuiApplication.setWindowIcon(QIcon)
Supported signatures:
  PySide6.QtGui.QGuiApplication.setWindowIcon(Union[PySide6.QtGui.QIcon, PySide6.QtGui.QPixmap])

Above its saying that the function setWindowIcon has a supported signature, which is something I've never seen before. And within the supported signature it says that the parameter for the function looks along the lines of this: Union[QIcon, QPixmap](<-- summarized form). I've never seen Union[] thing before so that is new to me as well.

Summary

  1. What is this error telling me?
  2. What is a Supported Signature?
  3. What is a Union[] supposed to be within parameters as shown in the suggested signature of the error?

CodePudding user response:

So I found out supported signatures specifies what objects you can pass into a parameter.

Union is another way of saying the parameters should be this object or the other.

So the supported signature: PySide6.QtGui.QGuiApplication.setWindowIcon(Union[PySide6.QtGui.QIcon, PySide6.QtGui.QPixmap]) Is saying that function PySide6.QtGui.QGuiApplication.setWindowIcon() accepts an object of type Pyside6.QtGui.QIcon or PySide6.QtGui.QPixmap.

  • Related