简体   繁体   English

Qt中的信号和插槽

[英]signals and slots in Qt

I was going through this Qt tutorial where I came across a pretty interesting line of code 我正在看这个Qt教程,那里遇到了非常有趣的代码行

connect(slider,SIGNAL(valueChanged(int)),this,SIGNAL(valueChanged(int)));   

Generally when a signal is emitted, then a slot is called. 通常,当发出信号时,将调用一个时隙。 What is meant by this statement? 这句话是什么意思? the "slider" is a QSlider object pointer. “滑块”是QSlider对象指针。

If helpful, this is the tutorial . 如果有帮助,请参阅本教程

This statement tells the qt signal/slot mechanism to connect two signals, making the second being emitted if the first one is emitted. 该语句告诉qt信号/插槽机制连接两个信号,如果发出第一个信号,则发出第二个信号。 Look at documentation of QObject::connect it has an example where a signal from a private member variable is made available by connecting it to a public signal of the owner class, but i guess that is just one use case. 看一下QObject :: connect的文档,它有一个示例,其中通过将私有成员变量的信号连接到owner类的公共信号来使其可用,但是我想那只是一个用例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM