[英]Qt 5.9 slot naming bug
I'm using Qt 5.9. 我正在使用Qt 5.9。
I've a problem declaring slots with underscore style in particular when I name it with more then 2 underscores.For example with a void on_stop_treatment()
slot, even I don't make a connection, I get QMetaObject::connectSlotsByName: No matching signal for on_stop_treatment()
. 我在声明带有下划线样式的插槽时遇到问题,特别是当我用两个以上的下划线
void on_stop_treatment()
例如,具有void on_stop_treatment()
插槽),即使我没有建立连接,我QMetaObject::connectSlotsByName: No matching signal for on_stop_treatment()
得到QMetaObject::connectSlotsByName: No matching signal for on_stop_treatment()
。
Anyway, making a connection, even if I get the same message, the slot signal mechanism works. 无论如何,建立连接,即使我收到相同的消息,插槽信号机制也能正常工作。 Removing the second underscore I get no error message and the mechanism works.
删除第二个下划线,我没有收到任何错误消息,并且该机制有效。 (I also tried deleting the moc file and rebuild)
(我也尝试过删除moc文件并重建)
Declaring your slot with the name on_stop_treatment
will clash with the Qt feature called Signal/Slot Automatic Connections 用名称
on_stop_treatment
声明插槽将与称为信号/插槽自动连接的Qt功能冲突
Qt will detect this specific syntax for your slot, and will try to match stop
with a QObject named stop
and treatment
with a signal of that name declared in the class of the QObject. Qt的将检测这个特定的语法您的插槽,并会尝试将
stop
与一个QObject命名stop
和treatment
与类QObject的的声明,名称的信号。
To achieve this, Qt uses internally QMetaObject::connectSlotsByName(this);
为此,Qt在内部使用
QMetaObject::connectSlotsByName(this);
to perform automatic signal/slot connections. 执行自动信号/插槽连接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.