QT paging navigation control and qt paging Control
Recently, when using QTableWidget, because there are many results and cell controls, paging is required to improve efficiency. I found some online, and finally modified on the basis of the http://www.cppblog.com/biao/archive/2011/10/30/159350.html, first of all thanks to the original author.
Modified Version: http://files.cnblogs.com/files/roadbike/PageNavigator.7z
New results, such as windows ):
Change Point:
After clicking the page number tab, if you have manually entered the page number, clear it first;
Address page number Tag Memory leakage;
The page number label padding is increased to 6 for convenient clicking (it may be a system difference. It seems that the margin of the original version is quite large, and it is very close to me in win10 );
The Delimiter is added between the previous page, the next page, and the page number to avoid clicking the next page by mistake to the page number );
SetStyleSheet is moved to the constructor;
Adjust the code format and class naming, and unify the parameter naming so that it complies with the standards of our project;
Other minor changes do not remember O (lead _ lead) O hahaha ~
Reference the original document and update the class name:
// Add the paging component to the current window
pageNavigator = new PageNavigator();
layout()->addWidget(pageNavigator);
When the total number of pages changes (such as querying the database to obtain the total number of pages), you only need to call the two functions of pageWidget.
void Widget::changeMaxPage() {
pageNavigator->setMaxPage(ui->lineEdit->text().toInt());
pageNavigator->setCurrentPage(1);
}
When the page number on pageNavigator is clicked, the void currentPageChanged (int page) signal is sent, and then the corresponding response is made in the main window, such as querying the database by page