TypeError: arguments did not match any overloaded call: QStandardItemModel(parent: typing.Optional[QObject] = None): argument 1 has unexpected type 'int' QStandardItemModel(rows: int, columns: int, parent: typing.Optional[QObject] = None): not enough arguments
时间: 2024-04-02 08:31:16 浏览: 51
这个错误是因为你在创建 QStandardItemModel 时,传递的参数类型与该函数所接受的参数类型不匹配。根据错误提示,QStandardItemModel 可以接受两种不同类型的参数:
1. 不传递参数,即使用默认参数。此时 QStandardItemModel 会以 None 作为 parent 参数创建一个空模型。
2. 传递 rows 和 columns 参数来指定模型的行数和列数,可以同时传递 parent 参数。
你的错误提示显示,你传递了一个 int 类型的参数,这个参数并不是 QStandardItemModel 所接受的任何一种参数类型。请确保你传递的参数类型与 QStandardItemModel 所需的参数类型匹配。
相关问题
TypeError: QTimer(parent: typing.Optional[QObject] = None): argument 1 has unexpected type 'Window'
这个错误是由于你在创建 `QTimer` 对象时将一个 `Window` 对象传递给了它的 `parent` 参数,但是 `QTimer` 的 `parent` 参数需要的类型是 `QObject`。因此,你需要将 `parent` 参数设置为 `None` 或者传递一个正确类型的 `QObject` 对象。
你可以尝试以下解决方法:
1. 将 `parent` 参数设置为 `None`:
```
timer = QTimer(None)
```
2. 将 `parent` 参数设置为合适的 `QObject` 对象,例如:
```
parent_obj = QObject()
timer = QTimer(parent_obj)
```
这样就可以解决这个错误了。
依据报如下错误: audio_out = QAudioDeviceInfo(devtxt) TypeError: arguments did not match any overloaded call: QAudioDeviceInfo(): too many arguments QAudioDeviceInfo(QAudioDeviceInfo): argument 1 has unexpected type 'str'
这个错误的原因是你在调用 QAudioDeviceInfo(devtxt) 的时候传递了一个字符串类型的参数,而实际上它需要的参数类型是 QAudioDeviceInfo 类型。你可以使用 QAudioDeviceInfo::availableDevices(QAudio::Mode mode) 方法来获取可用的音频设备列表,并从中选择一个合适的设备来创建 QAudioDeviceInfo 对象。具体的实现方式可以参考 Qt 官方文档以及相关的例子。