문제

I have a global QString object, and I would like to tie any changes to it to emit a Signal that I could connect to in other parts of my code.

I see that the QString Class doesn't have signals, so how would I go about doing this?

I'm using PyQt, but either a general Qt or a specific PyQt answer is much appreciated.

도움이 되었습니까?

해결책

I'd suggest that you wrap access to the QString in a singleton derived from QObject. Give the singleton a setter for the strings updated value, and emit a signal from the singleton if it has changed.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top