QT paging navigation control and qt paging Control

Source: Internet
Author: User

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

 

Related Article

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.