Three major forms of QT5

Source: Internet
Author: User

When you create a project, you find that the editor provides three base classes, respectively:
Qmainwindow, Qwidget, Qdialog, the differences between the three base classes are described below.
1, Qmainwindow
the Qmainwindow class provides a main application with a menu bar, an anchor window (such as a toolbar), and a status bar
program window. The main window is typically used to provide a large central window widget (such as text editing or drawing canvas) and
surrounding menus, toolbars, and a status bar. Qmainwindow are often inherited, as this enables the encapsulation of central components,
The toolbar and the window status bar are made easier, and when the user taps the menu item or toolbar button, the slot is
use.
2, Qwidget
the Qwidgt class is the base class for all user-interface objects. A widget is a basic unit of the user interface: It is from the window
The port system receives the mouse, keyboard, and other events and draws itself on the screen. Each widget is rectangular,
and they are arranged in the z-axis order. A widget can be covered by its parent window part or by a widget in front of it
part.
3, Qdialog
the Qdialog class is the base class for dialog Windows. The dialog window is primarily used for short-term tasks as well as for brief user
the top-level window for communication. Qdialog can be modal dialogs or non-modal dialog boxes. Qdialog supports extensibility and
and can provide a return value. They can have default buttons.

Of course, you can also add a new base class object to the main function

int main (int argc, char *argv[]) {    qapplication app (argc, argv);    Qwidget*window=new Qwidget;    Window->setwindowtitle ("Enter your Age");    Qspinbox *spinbox=new Qspinbox;    Qslider *slider = new Qslider (qt::horizontal);    Spinbox->setrange (0,130);    Slider->setrange (0,130);    Qobject::connect (Slider,signal (valuechanged (int)), Spinbox,slot (setValue (int)));    Qobject::connect (Spinbox,signal (valuechanged (int)), Slider,slot (setValue (int)));    Spinbox->setvalue (+);    Qhboxlayout*layout=new qhboxlayout;//Horizontal Layout, the next four lines are placed    //qhboxlayout-in horizontal direction from left to right layout;    //qvboxlayout- From top to bottom in a vertical direction;    //qgridlayout-is laid out in a grid, similar to the HTML table.    Layout->addwidget (spinbox);    Layout->addwidget (slider);    Window->setlayout (layout);    Window->show ();    return app.exec ();}

  

Three major forms of QT5

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.