In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain to you in detail about the application of the status bar at the bottom of Chammer Craft + Qt StatusBar, the content of the article is of high quality, so the editor will share it for you to do a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
A QstatusBar component is attached to the Qt form by default, and the status bar component is located at the bottom of the main form. Its function is to provide a tooltip function. When there is prompt information in the program, it can be dynamically displayed in this area. Any general component in the Qt can be added to the status bar component, which can be introduced to the bottom only by dynamic appending through the addWidget function. The bottom status bar is widely used in practical development. The following code is a summary of the basic usage of the component.
First, we add three new QLabel components through new, and arrange the components in the bottom status bar in turn. The implementation code is as follows:
# include "mainwindow.h" # include "ui_mainwindow.h" # include MainWindow::MainWindow (QWidget * parent): QMainWindow (parent), ui (new Ui::MainWindow) {ui- > setupUi (this); / / initialize the status bar QLabel * labCellIndex = new QLabel ("current coordinates: 0.0", this); labCellIndex- > setMinimumWidth (250); QLabel * labCellType=new QLabel ("Cell Type: null", this); labCellType- > setMinimumWidth QLabel * labStudID=new QLabel ("Student ID: 0", this); labStudID- > setMinimumWidth; / / add the initialized tag to the bottom status bar ui- > statusBar- > addWidget (labCellIndex); ui- > statusBar- > addWidget (labCellType); ui- > statusBar- > addWidget (labStudID);} MainWindow::~MainWindow () {delete ui;}
The effect of running code is as follows:
In addition to adding prompts, the QLabel component can be set to appear in the form of links by setting setOpenExternalLinks, which helps us to increase functions such as web page redirects.
# include "mainwindow.h" # include "ui_mainwindow.h" # include MainWindow::MainWindow (QWidget * parent): QMainWindow (parent), ui (new Ui::MainWindow) {ui- > setupUi (this); / / hide the triangle ui- > statusBar- > setSizeGripEnabled (false) below the status bar; / / add label bar QLabel * label_url = new QLabel (this); QLabel * label_about = new QLabel (this) / / configure connection label_url- > setFrameStyle (QFrame::Box | QFrame::Sunken); label_url- > setText (tr ("visit Home Page"); label_url- > setOpenExternalLinks (true); label_about- > setFrameStyle (QFrame::Box | QFrame::Sunken); label_about- > setText (about me); label_about- > setOpenExternalLinks (true) / / add information to the bottom (permanently add) ui- > statusBar- > addPermanentWidget (label_url); ui- > statusBar- > addPermanentWidget (label_about);} MainWindow::~MainWindow () {delete ui;}
The effect of running code is as follows:
Similarly, any generic component can be placed in the bottom menu bar. If we need to add a progress bar component, just write:
# include "mainwindow.h" # include "ui_mainwindow.h" # include # include QProgressBar * pro;MainWindow::MainWindow (QWidget * parent): QMainWindow (parent), ui (new Ui::MainWindow) {ui- > setupUi (this); pro = new QProgressBar (this); / / automatically calculate ui- > statusBar- > addPermanentWidget (pro, 1); / / set whether the progress shows pro- > setTextVisible (true) / / set initialization progress position pro- > setValue (0);} MainWindow::~MainWindow () {delete ui;} void MainWindow::on_pushButton_clicked () {qint32 count = pro- > value (); count = count + 10; pro- > setValue (count);}
The effect of running code is as follows:
Then we add a tablewidget and initialize parameters, tableWidget component there is an on_tableWidget_currentCellChanged attribute, the role of this attribute is, as long as there is a change in the Table table will trigger, when the user selects a different form, we can automatically set the current table row and column to the status bar, so as to achieve synchronization status bar message prompt, play the role of dynamic display at all times.
# include "mainwindow.h" # include "ui_mainwindow.h" # include # include # include QLabel * labCellIndex;MainWindow::MainWindow (QWidget * parent): QMainWindow (parent), ui (new Ui::MainWindow) {ui- > setupUi (this) / /-/ / initialize the status bar labCellIndex = new QLabel ("current coordinates: 0.0", this); labCellIndex- > setMinimumWidth / / add the initialized tag to the bottom status bar ui- > statusBar- > addWidget (labCellIndex) / /-/ / populate the data and initialize the table QStringList header; header tableWidget- > setHorizontalHeaderLabels (header) / / set the horizontal header ui- > tableWidget- > setRowCount (5); / / set the total number of rows ui- > tableWidget- > setEditTriggers (QAbstractItemView::NoEditTriggers); / / set the table structure to be non-editable by default / / populate the data QStringList NameList; NameList setItem (QString::number (AgeList [x]))) }} / / trigger the response event when the current selection cell changes, that is, set the bottom status bar label to / / https://www.cnblogs.com/lysharkvoid MainWindow::on_tableWidget_currentCellChanged (int currentRow, int currentColumn, int previousRow, int previousColumn) {Q_UNUSED (previousRow); Q_UNUSED (previousColumn); / / display the change values of rows and columns / / std::cout
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.