User Tools

Site Tools


en:code:examples

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:code:examples [2016/10/09 11:10] (current)
Line 1: Line 1:
 +===Show a custom dialog box===
 +<code javascript>​
 +var window = new QDialog();
 +var layout = new QFormLayout(window);​
 +var nameLineEdit = new QLineEdit(window);​
 +var ageSpinBox = new QSpinBox(window);​
 +var buttonBox = new QDialogButtonBox(window);​
  
 +buttonBox.addButton(QDialogButtonBox.Ok);​
 +buttonBox.addButton(QDialogButtonBox.Cancel);​
 +
 +buttonBox.accepted.connect(window.accept);​
 +buttonBox.rejected.connect(window.reject);​
 +
 +layout.addRow("​Name:",​ nameLineEdit);​
 +layout.addRow("​Age:",​ ageSpinBox);​
 +layout.addRow(buttonBox);​
 +
 +if(window.exec() == QDialog.Accepted)
 + MessageBox().setText("​Your name is " + nameLineEdit.text + "\nYou are " + ageSpinBox.value + " years old."​).showModal();​
 +</​code>​
en/code/examples.txt ยท Last modified: 2016/10/09 11:10 (external edit)