Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Qt Container window in C++

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to use the Qt container window in C++, the article is very detailed, has a certain reference value, interested friends must read it!

Container (Container)

Various container windows are available in Qt:

1. Tab window QTabWidget

2. Stacking window QStackedWidget

3. Tool window QToolBox

I. Tab window

Holds multiple child windows, each displaying a tab (tab). When the tab is clicked, this window is placed at the top.

Implementation method:

1. Use Qt Designer

2. Add Widget manually

II. Stacking window

Accommodate multiple Widget, each Wdiget is called a page

No label, controlled by other windows

You can usually do a wizard program.

Which page is displayed: setCurrectIndex ()

Little exercise: make an interface like this:

Test9_2a_12_9::Test9_2a_12_9 (QWidget * parent): QMainWindow (parent) {ui.setupUi (this) Assert (connect (ui.btnPage1, SIGNAL (clicked ()), this, SLOT (OnBtnPage1 () Assert (connect (ui.btnPage2, SIGNAL (clicked ()), this, SLOT (OnBtnPage2 () Assert (connect (ui.btnPage3, SIGNAL (clicked ()), this, SLOT (OnBtnPage3 () } int Test9_2a_12_9::OnBtnPage1 () {ui.stackedWidget- > setCurrentIndex (0); return 0;} int Test9_2a_12_9::OnBtnPage2 () {ui.stackedWidget- > setCurrentIndex (1); return 0;} int Test9_2a_12_9::OnBtnPage3 () {ui.stackedWidget- > setCurrentIndex (2); return 0;}

III. Tool window

Accommodate multiple Widget, each Wdiget is called a page

Small exercise:

Make the following interface

Implementation code:

Test9_3a_12_9::Test9_3a_12_9 (QWidget * parent): QMainWindow (parent) {ui.setupUi (this) Assert (connect (ui.btnName, SIGNAL (clicked ()), this, SLOT (OnBtnName () Assert (connect (ui.btnPasswd, SIGNAL (clicked ()), this, SLOT (OnBtnPasswd () Assert (connect (ui.btnLogin, SIGNAL (clicked ()), this, SLOT (OnBtnLogin () } int Test9_3a_12_9::OnBtnName () {ui.stackedWidget- > setCurrentIndex (0); return 0;} int Test9_3a_12_9::OnBtnPasswd () {ui.stackedWidget- > setCurrentIndex (1); return 0;} int Test9_3a_12_9::OnBtnLogin () {ui.stackedWidget- > setCurrentIndex (2); return 0 } these are all the contents of this article entitled "how to use the Qt Container window in C++". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report