C ++ Gui Programming with QT3 (series of test)

xiaoxiao2021-03-06  86

Chapter 1 getting started first chapter starts QT journey

This Chapter Shows How To Combine Basic C with the functionality provided by qt to create a few small graphical user intFector (GUI) Application. This chapter will display how to create some simple user graphics interfaces (GUI) in C features application. This Chapter Also Introduces Two Key Qt Ideas: "Signals and Slots" and Loyouts.in Chapter 2, We Will Go Into More Depth, And in Chapter 3, We will Start Building A Realistic Application. This chapter also introduces two important in QT Concept: Signal and Signals and Layouts (Translated: On the Form). In the second chapter, there is also a more in-depth discussion on this two concepts. In the third chapter, it began to establish a real application. Here's a Very Simple Qt Program: Here is a very simple QT program 1 #inclue 2 #inclue

3 int main (int Argc, char * argv []) 4 {5 QApplication App (Argc, Argv); 6 QLabel * label = new QLabel ("Hellow Qt!", 0); 7 App.SetMainWidget (Label); 8 Label-> show (); 9 return app.exec (); 10} We will first study it line by line, then we will see how to compile and run it. Let's learn from a line, then look at how to go Compile and implement him. LINES 1 and 2 include the definitions of the qapplication and qlabel classes. The first and second rows contain headers that define QApplication and QLabel.

Line 5 create a QApplication object to manage application-wide resources.The QApplication constructor requires argc and argv because Qt supports a few commdand-line arguments of its own. The fifth line creates a QApplication object. This object is used to manage applications levels (translation: all visible throughout applications). The constructor of QApplication requires both parameters of Argc and Argv. That's because QT itself supports command line parameters. Line 6 create a QLabel widget that displays In Qt terminology, a widget is a element in a user interface.Buttons, menus, scroll bars, and frames are all examples of widgets.Widgets can contain other widgets "Hello Qt!";. For example, an application window is usually a widget that contains a QMenuBar, a QToolBar, a QStarusBar, and some other widgets.The 0 argument to the QLabel constructor (a null pointer) means that the widget is a window in its own rigt, not A Widget Inside Another Window. The sixth line creates a QLabel Form Control (Widget) to display "Hellow Qt!". In QT, the Form Control (Translation: Widget) is a visible element in the user interface. Buttons (Translation: Menu), Scroll Bars (Translation: Scroll Bar) and Frame All Form Controls. Form controls can accommodate other form controls. For example, an application form is usually a form control containing a QMenubar (translation: menu), QToolbar, and other Widgets. Parameter 0 Give the QLabel Constructor (a null pointer) indicates that the form control is a top-level form control, he is not included in any other form. Line 7 make the label the application's main main widget.When the user closes the main widget (by clicking X in the windows's title bar, for example), the program terminates.Without a main widget, the program would keep runing in the background even After the user has closed the window. Settings Label sets the main form control for the application. When the user turns off the main form control (for example, the x on the title bar of the form, the program will stop running. If there is no main form control, the program will run in the background, even if the form has been turned off.

转载请注明原文地址:https://www.9cbs.com/read-95505.html

New Post(0)