QML:如何实现子进程的信号处理程序

时间:2016-12-23 14:17:05

标签: qt qml qt-creator

我正在编辑Qt Creator中的组件。它建议我在UI中拆分组件,而不是UI部分。我的组件公开了2个自定义属性。

ComponentViewForm {
    property string step: '0'
    property string setStep: '0'
}
  1. UI-Part内的TextInput绑定到step
  2. 应在setStep处理程序中设置属性onAccepted
  3. 第一个很容易。可以直接在UI-Editor中编辑绑定 但是,我如何实现孩子的信号处理程序? 我直接在UI中实现了它。

    TextInput {
        id: step
        text: parent.step
        onAccepted:
        {
            parent.setStep = text
        }
    }
    

    它有效,但Qt-Creator拒绝再以UI模式打开它。

1 个答案:

答案 0 :(得分:2)

您可以TextInput ComponentViewForm TextInput stepInput。在Qt Quick UI表单编辑器的 Navigator 选项卡中有一个小的 Export 按钮。假设property alias stepInput: stepInput的id为ComponentViewForm { property string step: '0' property string setStep: '0' stepInput.text: step stepInput.onAccepted: { setStep = stepInput.text; } } ,单击导出按钮后,ComponentViewForm.ui.qml在源代码中应具有别名属性ALTER FUNCTION [dbo].[checkDate] (@dt datetime) RETURNS bit AS BEGIN IF EXISTS ( SELECT * FROM TableB WHERE checkDate is between [Starting Date] and [Deadline] ) RETURN 1 RETURN 0 END export

您可以在ComponentView.qml中实现属性绑定和信号处理程序,如下所示:

ALTER TABLE [dbo].[TableA]  
WITH NOCHECK ADD CHECK  (([dbo].[checkDate]([Date1])=(0)))