QT GUI @ Create a new project

Source: Internet
Author: User
Tags qt designer

Development environment:

Qt 4.5

Qt Creator 1.3.0

New Project Creation steps:

1. Click Run QT Creator to enter the Welcome page. Select "File", "New file or Project ...";

2. In the pop-up window select "Qt4 Gui Application", click OK, next;

3. Select the path to save the project and define your own project name (the path does not have Chinese and white space), the next step;

4. The "Select Required modules" interface appears. Then add some functional modules according to your needs.

What are the specific types of modules used? Google, after finishing.

5. Select the base class and select Generate form as needed, then finish.

qwidget Qmainwindow Qdialog three different base classes:

  the Qwidget class is the base class for all user-interface objects. A widget is an atom of the user interface: it receives mouse, keyboard, and other events from the window system and plots its own performance on the screen. Each widget is a rectangle, and they are arranged in the z-axis order. A widget can be partially covered by its parent window part or by a window part in front of it.
  the Qmainwindow class provides a main application window with a menu bar, an anchor window (such as a toolbar), and a status bar . The main window is typically used to provide a large central widget (such as text editing or drawing the canvas) along with the surrounding menus, toolbars, and a status bar. Qmainwindow is often inherited because it makes it easier to encapsulate central parts, menus, and toolbars, as well as window states. Inheritance makes it possible to create slots that are called when a user taps a menu item or a toolbar button. You can also use the QT Designer to create a main window.
  the Qdialog class is the base class for dialog Windows . A dialog window is a top-level window that is primarily used for short-term tasks and for brief communication with users. Qdialog can be modal or non-modal. Qdialog supports extensibility and can provide return values. They can have default buttons. Qdialog can also have a qsizegrip in the lower right corner of it, using setsizegripenabled (). Qdialog is the most common top-level window. Widgets that are not embedded in a parent widget are called top-level widgets. Typically, a top-level widget is a window with frames and title bars (although it may not be possible to create a top-level window part if a certain window part tag is used). In Qt, Qmainwindow and different qdialog subclasses are the most common top-level windows.
  If it is a top-level dialog box, it is created based on Qdialog, and if it is the main form, it is based on Qmainwindow, if it is not, or if it is possible to be a top-level form, or possibly embedded in another form, is created based on Qwidget.
Of course, in practice, you can also derive based on any other part class. See the actual needs, such as Qframe, Qstackedwidget and so on.

See the QT development framework from a simple QT program

#include <QApplication> #include <qlabel>int main (int Argc,char **argv) {    qapplication app (ARGC,ARGV);    Qlabel label;    Label.settext ("

The first line: #include <qapplication>: This is what each GUI application needs to introduce in order to instantiate Qapplication objects and manage QT resources

The second line, #include <qlabel>: This is a winget of a visual GUI space in Qt

    The main function, qapplication an object, is to ensure that the event loop is valid, and the end of App.exec () is the event loop management to Qt, and then each event in QT mode to be issued and processed.

The third line, Qlabel label shows a qt visual widget, which can be used as the top-level window, QT is the simplest display control, mainly to complete the display of strings and pictures. We will discuss this control in detail later.

Row four, SetText sets the Qlabel output string. This string can be used to complete different styles using HTML simple markup, as in this example <i> oblique display www.it165.net

Line five, call show to display the controllable program, its default state is not displayed

Row six, exec is the time loop to QT, in fact, a waiting loop, and other events triggered, such as Get focus, button click and so on

It is important to note that the Qapplciaton app and app.exec are necessary for the Qtgui program entry and event loop, which is the most basic framework for developing QT programs.

  

QT GUI @ Create a new project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.