TopEcmaGui Class

在js脚本中动态显示对话框、可过滤的表格选择、消息对话框 More...

Header: #include <TopEcmaGui>
Inherits: QObject

Public Slots

QString debug(const QScriptValue &params)
QVariant msgbox(const QScriptValue &iParams)
QVariant showFilterTableDialog(const QScriptValue &iParams)
QVariant showForm(const QScriptValue &iParams)
QVariant showMasterSlaveTableDialog(const QScriptValue &iParams)
QVariant showTableChooserDialog(const QScriptValue &iParams)
  • 1 public slot inherited from QObject

Static Public Members

TopEcmaGui *instance()
  • 10 static public members inherited from QObject

Protected Functions

  • 9 protected functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 31 public functions inherited from QObject
  • 2 signals inherited from QObject
  • 1 public variable inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

在js脚本中动态显示对话框、可过滤的表格选择、消息对话框

Member Function Documentation

[protected] TopEcmaGui::TopEcmaGui()

Default constructs an instance of TopEcmaGui.

[protected] TopEcmaGui::~TopEcmaGui()

Destroys the instance of TopEcmaGui.

[slot] QString TopEcmaGui::debug(const QScriptValue &params)

[static] TopEcmaGui *TopEcmaGui::instance()

[slot] QVariant TopEcmaGui::msgbox(const QScriptValue &iParams)

用于在js脚本中动态加载显示消息对话框。


  GUI.msgbox({
      'type':'INFO',
      'title':'Message Box'
      'text':'The MessageBox Show Text.',
      'detail':'Details',
      'buttons':[
         self.ttr('Ok') + ':Ok:Ok:Primary',
         self.ttr('Cancel') + ':Cancel:Cancel:Normal'
      ],
      'default_button':'',
  });

type的值有:'INFO','OK','WARN','ERROR','ASK'以及'QUESTION'。

一般使用较为简单,传入需要显示的内容和标题:


  GUI.msgbox({
      title:'Notice',
      text:self.ttr('This is message box.')
  });

即可。

[slot] QVariant TopEcmaGui::showFilterTableDialog(const QScriptValue &iParams)

用于在JS脚本中显示可过滤的表格选择对话框

[slot] QVariant TopEcmaGui::showForm(const QScriptValue &iParams)

用于在js脚本中动态加载显示对话框。

首先定义要显示的控件,它将作为items属性的值:


  var widget = {
      name:"user",
      type:"LineEdit",
      title:self.ttr("User"),
      property:{},
      pack:{
          label:self.ttr("User")
      }
  };

在js中调用该showForm函数时,以GUI.showForm(...)形式调用:


  var ret = GUI.showForm({
      'title': self.ttr("Add Script"),  // 窗口名称
      'self': self,                     // 设置self变量
      'use_core_engine': true,          // 使用框架的解析引擎,一般都是true
      'items': widget,                  // 窗口内显示的控件
      'size': '400x300',                // 窗口尺寸
      'icon': 'bug',                    // 设置窗口icon
      'values':{                        // 这个用于向该窗口内的控件传递值
          'user':'TestUserName',
          ...
      }
  });

ret 是从该窗口各控件中返回的值。

其它参数还有:

include_hidden_items,用于指定在返回值时是否包含隐藏项的值。

ui,加载其他js界面文件:


  // 假如我们已经有了一个login.js
  'ui': self.ui('login')

buttons,指定对话框显示的按钮样式:


  'buttons': [
      self.ttr('Ok') + ':Ok:Ok:Primary',
      self.ttr('Cancel') + ':Cancel:Cancel:Normal'
  ],

[slot] QVariant TopEcmaGui::showMasterSlaveTableDialog(const QScriptValue &iParams)

[slot] QVariant TopEcmaGui::showTableChooserDialog(const QScriptValue &iParams)