Qt5 layout management (1)

Source: Internet
Author: User

1. Split the window qsplitter

(1) qsplitter constructor:

Qsplitter * splittermain = new qsplitter (QT: horizontal, 0 );

The first parameter is set to horizontal or vertical using QT: horizontal and QT: vertical. The second setting 0 indicates the main window without a parent window. When 0 is replaced with splittermain, it indicates that the main window is used, and the Child splitter is added to splittermain.

Common statements

① Set whether to update in real time when dragging:

Splitterright-> setopaqueresize (false );

False indicates that it is not updated in real time (only one gray line is displayed when you drag it, and the split lines are displayed after you drag it in place and release the mouse ). The default value is true (Real-time update ).

② Specify the font display:

Qfont font ("font type", size );

A. setfont (font );

③ Text alignment:

Example: Object-> setalignment (QT: aligncenter)

④ Splittermain-> setstrechfactor (): used to set a Scalable Control. The first parameter specifies the control serial number, and the second parameter is greater than 0, indicating that the control is a Scalable Control.


2. Call window qdockwidget class:

(1) create a docking form for the qdockwidget object:

Qdockwidget * dock = new qdockwidget (TR ("dockwindow"), this );

(2) set the features of the dock form:

Object-> setfeatures (qdockwidget: dockwidgetmovable); Movable

Dockwidgetclosables can be disabled

Dockwidgetfloatable floatable

Alldockwidgetfeatures has all the features of the dock form

Nodockwidgetfeatures cannot be moved, closed, or floating

(3) setallowedareas:

Object-> setallowedareas (QT: dockwidgetareas areas );

Qt: leftdockwidgetarea can be docked on the left side of the window

Qt: rightdockwidgetarea can be docked at the right of the window

Qt: topdockwidgetarea can be docked at the top of the window.

Qt: bottomdockwidgetarea can be docked at the bottom of the window

Qt: alldockwidgetarea can be docked in any direction of the window

Qt: nodockwidgetarea can only be docked at the Insert Location




Qt5 layout management (1)

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.