AxForm type

Namespace Form

The form namespace contains functions and objects for working with UI elements such as buttons, input fields, tables, and dialogs.

All visual elements have the following methods:

  • void setEnabled(bool enable) - if enable == true the element will be enabled, otherwise it will be disabled.

  • void setVisible(bool enable) - if enable is true the element will be visible, otherwise it will be hidden.

  • bool getEnabled() - returns true if the element is enabled.

  • bool getVisible() - returns true if the element is visible.

Connect

AxScript uses QT signal-slot technology. A signal is emitted when a particular event occurs. A slot is a function that is called in response to a particular signal. Qt's signals and slots mechanism ensures that if you connect a signal to a slot, the slot will be called with the signal's parameters at the right time. Signals and slots can take any number of arguments of any type. They are completely type safe.

You can connect as many signals as you want to a single slot, and a signal can be connected to as many slots as you need. It is even possible to connect a signal directly to another signal. (This will emit the second signal immediately whenever the first is emitted.)

form.connect(element elem, string signal, function(){}) - Creates a connection from the signal in the elem object to the function handler.

Example
let btn = form.create_button("Send signal");

form.connect(btn, "clicked", function(){
    ax.show_message("test", "Clicked signal");
});

let layout = form.create_vlayout();
layout.addWidget(btn);

let dialog = form.create_dialog("");
dialog.setLayout(layout);
dialog.exec()

Container

To retrieve data in JSON format from input elements, you must use a container object.

Methods:

1

put

This method adds an element elem with the given id to the container.

2

get

This method gets an element from the container by the given id.

3

contains

This method checks if an element with the given id exists in the container.

4

remove

This method removes the element with the given id from the container.

5

toJson

This method packs the data of all container elements into JSON format.

6

fromJson

This method recovers the values of elements in a container from a JSON string jsonString.

Example

VLayout / HLayout

The vlayout class lines up elements vertically. The hlayout class lines up elements horizontally.

To create a vlayout/hlayout element, use the form.create_vlayout() / form.create_hlayout() function.

Methods:

1

addWidget

Adds element to the end of this box layout.

Example

GridLayout

The gridlayout class lays out elements in a grid.

To create a gridlayout element, use the form.create_gridlayout() function.

Methods:

1

addWidget

Adds the given element to the cell grid, spanning multiple rows/columns. The cell will start at row, col spanning rowSpan rows and colSpan columns.

Example

VLine / HLine

The line element is a simple divider cover.

To create a vline / hline element, use the form.create_vline() / form.create_hline() function.

Example

VSpacer / HSpacer

The spacer element provides blank space in a layout. Normally, you don't need to use this element directly.

To create a vspacer / hspacer element, use the form.create_vline() / form.create_hline() function.

Example

Basic

With hspacer


Label

The label element provides a text display.

element create_label(string text = "") - Constructs a label that displays the text, text.

Methods:

1

text

This property holds the label's text. If no text has been set this will return an empty string.

2

setText

This method sets the label text, text.

Example

TextLine

The textline element is a one-line text editor.

element create_textline(string text = "") - Constructs a textline containing the text, text.

Methods:

1

text

This property holds the textline's text. If no text has been set this will return an empty string.

2

setText

This method sets the textline text, text.

3

setPlaceholder

This method sets the textline placeholder text, text.

4

setReadOnly

This method holds whether the textline is read-only.

Signals:

1

textChanged

This signal is emitted whenever the text changes. The text argument is the new text.

2

textEdited

This signal is emitted whenever the text is edited. The text argument is the new text.

3

returnPressed

This signal is emitted when the Return or Enter key is used.

4

editingFinished

This signal is emitted when the Return or Enter key is used, or if the textline loses focus and its contents have changed since the last time this signal was emitted.

Example

TextMulti

The textmulti element provides a widget that is used to edit and display text.

element create_textmulti(string text = "") - Constructs a textmulti containing the text, text.

Methods:

1

text

This property holds the textmulti's text. If no text has been set this will return an empty string.

2

setText

This method sets the textmulti text, text.

3

appendText

Appends a new paragraph with text to the end of the textmulti.

4

setPlaceholder

This method sets the textmulti placeholder text, text.

5

setReadOnly

This method holds whether the textmulti is read-only.

Example

DateLine

The dateline element provides a widget for editing dates.

element create_dateline(string format = "dd.MM.yyyy") - Constructs a dateline. The format used to display the date of the date edit.

Methods:

1

dateString

This method return the date that is set in the element.

2

setDateString

This method set the date in the element.

Example

TimeLine

The timeline element provides a widget for editing times.

element create_dateline(string format = "HH:mm.yyyy") - Constructs a timeline. The format used to display the time of the time edit.

Methods:

1

timeString

This method return the time that is set in the element.

2

setTimeString

This method set the time in the element.

Example

Combo

The combo element combines a button with a dropdown list.

element create_combo() - Constructs a combo.

Methods:

1

addItem

Adds an item to the combo with the given text.

2

addItems

Adds each of the strings in the given array to the combo. Each item is appended to the list of existing items in turn.

3

setItems

Clears the combo and adds each of the strings in the given array to the combo.

4

clear

Clears the combo.

5

currentText

This method set the current text.

6

setCurrentIndex

This method set the current item by the index.

7

currentIndex

This method return the index of the current item.

Signals:

1

currentTextChanged

This signal is emitted whenever currentText changes. The new value is passed as text.

2

currentIndexChanged

This signal is emitted whenever currentIndex changes. The new index is passed as number.

Example

Spin

The spin element provides a spin box widget.

element create_spin() - Constructs a spin with 0 as minimum value and 99 as maximum value, a step value of 1. The value is initially set to 0.

Methods:

1

value

This method return the value of the spin.

2

setValue

This method set the value of the spin.

3

setRange

Convenience method to set the min, and max values with a single function call.

Signals:

1

valueChanged

This signal is emitted whenever the spin's value is changed. The new value's passed as integer value.

Example

Check

The check element provides a checkbox with a text label.

element create_check(string label= "") - Constructs a checkbox with the given text.

Methods:

1

isChecked

This method return true if the button is checked.

2

setChecked

This method sets the checked state.

Signals:

1

stateChanged

This signal is emitted whenever the check state changes, i.e., whenever the user checks or unchecks it.

Example

Button

The button element provides a command button.

element create_button(string text= "") - Constructs a button with the text text.

Signals:

1

clicked

This signal is emitted when the button is activated.

Example

List

The list element provides an item-based list widget.

element create_list() - Constructs an empty list.

Methods:

1

items

Returns an array of elements.

2

addItem

Inserts the item at the end of the list widget.

3

addItems

Inserts items at the end of the list widget.

4

removeItem

Removes the element at the specified index.

5

itemText

Return the element at the specified index.

6

setItemText

Set the item at the specified index.

7

clear

Removes all items and selections.

8

count

This method return the number of items in the list including any hidden items.

9

currentRow

This method return the row of the current item.

10

setCurrentRow

This method sets the row of the current element at the specified index.

11

selectedRows

Returns an array of selected elements.

12

setReadOnly

This method holds whether the list is read-only.

Signals:

1

currentTextChanged

This signal is emitted whenever the current item changes. currentText is the text data in the current item. If there is no current item, the currentText is invalid.

2

currentRowChanged

This signal is emitted whenever the current item changes. currentRow is the row of the current item. If there is no current item, the currentRow is -1.

3

itemClickedText

This signal is emitted with the specified text when a mouse button is clicked on an item in the list.

4

itemDoubleClickedText

This signal is emitted with the specified text when a mouse button is double clicked on an item in the list.

Example

Table

The table elements provides an item-based table view.

element create_table(string[] headers) - Creates a new table view with the given headers.

Methods:

1

addColumn

This method adds a new column to the table with the specified header.

2

setColumns

This method adds new columns to the table with the specified headers.

3

addItem

Inserts item at the end of the table, item is an array of strings, the string index corresponds to the column index.

4

rowCount

Returns the number of rows.

5

columnCount

Returns the number of columns.

6

text

This property contains the cell text for the specified row and column. If no text is specified, an empty string is returned.

7

setItemText

Set the cell text for the specified row and column.

8

clear

Removes all items from table.

9

setRowCount

Sets the number of rows in this table's.

10

setColumnCount

Sets the number of cols in this table's.

11

currentRow

This method return the row of the current cell.

12

currentColumn

This method return the column of the current cell.

13

hideColumn

Hide the given column.

14

selectedRows

Returns an array of arrays of the selected elements.

15

setReadOnly

This method holds whether the table is read-only.

16

setSortingEnabled

If enable is true, enables sorting for the table

17

resizeToContent

Will automatically resize the section to its optimal size based on the contents of the entire column.

18

setHeadersVisible

If enable is true, the column in the table will be visible, otherwise hidden.

19

setColumnAlign

Sets the alignment in the column. Available values are "left", "right", "center".

Signals:

1

cellChanged

This signal is emitted whenever the data of the item in the cell specified by row and column has changed.

2

cellClicked

This signal is emitted whenever a cell in the table is clicked. The row and column specified is the cell that was clicked.

3

cellDoubleClicked

This signal is emitted whenever a cell in the table is double clicked. The row and column specified is the cell that was double clicked.

Example

Panel

The panel element provides a placement of other elements using layout.

element create_panel() - Constructs a panel.

Methods:

1

setLayout

Sets the layout manager for this element to lt.

Example

GroupBox

The groupbox element provides a group box frame with a title.

element create_groupbox(string title, bool checkable) - Constructs a groupbox with the given title. Property checkable holds whether the group box has a checkbox in its title.

Methods:

1

isChecked

This method return true if the checkbox is checked.

2

setChecked

This method sets the checked state.

3

isCheckable

If this property is true, the group box displays its title using a checkbox in place of an ordinary label.

4

setCheckable

If checkable is true, the group box displays its title using a checkbox in place of an ordinary label.

5

setTitle

This method sets the title text of the group box.

6

setPanel

This method sets an element inside a groupbox.

Signals:

1

clicked

This signal is emitted when the check box is activated

Example

ScrollArea

The scrollarea element provides a scrolling view onto another elements.

element create_scrollarea() - Constructs an empty scrollarea.

Methods:

1

setWidgetResizable

This property holds whether the scrollarea should resize the view element.

2

setPanel

This method sets an element inside a scrollarea.

Example

VSplitter / HSplitter

The splitter element implements a splitter widget.

To create a vsplitter / hsplitter element, use the create_vsplitter() / form.create_hsplitter() function.

Methods:

1

setSizes

Sets the child elements respective sizes to the values given in the sizes.

2

addPage

Adds the given elem to the splitter's layout after all the other items.

Signals:

1

splitterMoved

This signal is emitted when the splitter handle at a particular index has been moved to position pos.

Example

Tabs

The tabs element provides a stack of tabbed widgets.

element form.create_tabs() - Constructs a tabs element.

Methods:

1

addTab

Adds a tab with the given elem and title to the tabs.

Example

Stack

The stack element provides a stack of widgets where only one widget is visible at a time.

element create_stack() - Constructs a stack.

Methods:

1

addPage

Appends the given page to the stask and returns the index position.

2

insertPage

Inserts the given page at the given index in the stack.

3

removePage

Removes element from the stack by index.

4

setCurrentIndex

This method set the index position of the widget that is visible;

5

currentIndex

This method return the index position of the widget that is visible;

6

count

This method return the number of elements contained by this stack.

Signals:

1

currentChanged

This signal is emitted whenever the current element changes.

Example

Dialog

The dialog element is implement of dialog windows.

dialog create_dialog(string title) - Constructs a dialog with title.

Methods:

1

setButtonsText

This method sets the text ok_text for button OK and the text cancel_text for button CANCEL.

2

setSize

This method sets the size for the window.

3

setLayout

Sets the layout manager for this window.

4

close

Close window.

5

exec

Shows the dialog as a modal dialog, blocking until the user closes it. If the window is closed by pressing the OK button, the method will return true.


Last updated