Skip to content

Bug: 在类SiCapsuleLineEdit的_drawIndicatorRect方法中,代码会因 QSize 参数类型错误引发 TypeError #286

@ConcatLMX

Description

@ConcatLMX

错误日志

Traceback (most recent call last):
File "D:\anaconda\envs\window\Lib\site-packages\pyqt_siliconui-1.0.1-py3.11.egg\siui\components\editbox.py", line 411, in paintEvent
self._drawIndicatorRect(painter, text_rect)
File "D:\anaconda\envs\window\Lib\site-packages\pyqt_siliconui-1.0.1-py3.11.egg\siui\components\editbox.py", line 394, in _drawIndicatorRect
indi_rect = QRect(shrunk_rect.topLeft() + QPoint(16, 34), QSize(self._text_indi_width + 8, 2))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: arguments did not match any overloaded call:
QSize(): too many arguments
QSize(w: int, h: int): argument 1 has unexpected type 'float'
QSize(a0: QSize): argument 1 has unexpected type 'float'

描述

siui/components/editbox.py中的类SiCapsuleLineEdit的_drawIndicatorRect方法尝试使用一个浮点数self._text_indi_width来构造 QSize 对象。QSize的构造函数期望接收整数作为参数,因此这会导致 TypeError,并导致应用程序崩溃。

可能的修复方法

用int()直接将self._text_indi_width显式地转换为整数。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions