Creating a Basic Window in Qt
This is a basic piece of code to get you started with the QT Jambi API. Ensure that you have the QT libraries installed before you try and run this code. IF you don’t have this then it won’t run properly and will throw an error. This displays a basic window. Nothing added to it just a basic QT Jambi Window.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import com.trolltech.qt.gui.*; public class basicWindow { private final int WINDOW_WIDTH = 500; private final int WINDOW_HEIGHT = 400; private QFrame frame; public basicWindow() { //create the frame frame = new QFrame(); //create the size of the window frame.resize(WINDOW_WIDTH, WINDOW_HEIGHT); //create the layout for the window QGridLayout gridLayout = new QGridLayout(); //add the layout to the main frame frame.setLayout(gridLayout); frame.show(); } public static void main(String[] args) { //Used to initialize the window QApplication.initialize(args); //creates a new instance of the basicWindow new basicWindow(); //runs the window as an application QApplication.exec(); } } |
Cheers