带条件的信号和槽
signals and slots with a condition
我有一个带有 QLineEdit_1 的 mainwindow.ui 和带有多个 QLineEdit 小部件的 secondWindow.ui ,简而言之,我想在 [=17 中输入特定数字时创建一个条件=] 将导致某些 QLineEdit 小部件上的文本输出为 "null",其余部分仍为空白。
实现上述目标的主要步骤是什么
如果还有人会引导我找到一个类似的例子,那就太好了
谢谢。
听起来您正在搜索信号槽连接:http://doc.qt.io/qt-5/signalsandslots.html。
在你的情况下,听 QLineEdit_1 的 textChanged()
并在例如secondWindow.ui-class 其他行随意设置:
connect(QLineEdit_1, &QLineEdit::textChanged,
PointerToSecondWindow, &secondWindow::yourSlot);
// In secondWindow.cpp
void secondWindow::yourSlot(const QString &text) {
// Do with text whatever you like and set the
// other line edits.
}
我有一个带有 QLineEdit_1 的 mainwindow.ui 和带有多个 QLineEdit 小部件的 secondWindow.ui ,简而言之,我想在 [=17 中输入特定数字时创建一个条件=] 将导致某些 QLineEdit 小部件上的文本输出为 "null",其余部分仍为空白。
实现上述目标的主要步骤是什么 如果还有人会引导我找到一个类似的例子,那就太好了 谢谢。
听起来您正在搜索信号槽连接:http://doc.qt.io/qt-5/signalsandslots.html。
在你的情况下,听 QLineEdit_1 的 textChanged()
并在例如secondWindow.ui-class 其他行随意设置:
connect(QLineEdit_1, &QLineEdit::textChanged,
PointerToSecondWindow, &secondWindow::yourSlot);
// In secondWindow.cpp
void secondWindow::yourSlot(const QString &text) {
// Do with text whatever you like and set the
// other line edits.
}