Qt Script Tetrix ExampleFiles:
The QSTetrix example is a Qt Script version of the classic Tetrix game. The program logic in this example is a fairly straight port of the logic in the C++ Tetrix Example. You may find it useful to compare the implementations of the TetrixBoard, TetrixPiece and TetrixWindow classes to see how Qt Script is used to implement methods, call Qt functions, and emit signals. The graphical user interface is defined in a UI file, created using Qt Designer, and is set up in the example's C++ main.cpp file. We define a custom UI loader that handles our TetrixBoard widget; this is the main component of the UI (where the pieces are drawn). We initialize the script engine to have the Qt namespace, so that e.g., Qt.Key_Left will be available to script code. We also make the application object available (for the quit() slot). Several scripts are evaluated as part of the engine setup process. The tetrixpiece.js file contains the definition of the TetrixPiece class, which is used to populate the play field. The tetrixboard.js file contains the definition of the TetrixBoard class, which contains the main game logic. Finally, tetrixwindow.js contains the definition of the TetrixWindow class, which wires up the top-level widget. A form is created from the UI file. A new TetrixWindow script object is then constructed, passing the form as its argument. The form is shown, and the event loop is entered. © 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. Privacy Policy Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia. Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. |