Giter Site home page Giter Site logo

hwdqm88 / qpagebar Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 22 KB

A paging component (page bar) based on Qt 5/Qt 6 ------------- 基于Qt 5/Qt 6的分页条控件(page bar)

License: Apache License 2.0

C++ 100.00%
qt qt5 qt5-gui qt5-widgets qt6 qt6-gui qt6-widgets

qpagebar's Introduction

QPageBar

点击这里切换为中文

1. Introduction

QPageBar is a Qt widget based on Qt 5/Qt 6, which can be used to implement the page switching function (similar to various forum page bars, where you can switch pages by clicking on the page number or entering the page number).

2. Usage

1. Import files

Simply import the qpagebar.h and qpagebar.cpp files in the src folder into the project to use. (The Chinese folder contains comments in Chinese, while the English folder contains comments in English.)

2. Declare the QPageBar class

There are two ways to declare the QPageBar class:

The first method has only one parent parameter:

QPageBar(QWidget* parent = nullptr);
  • This constructor has only one parent parameter, so you can directly declare QPageBar in the .ui file, and Qt's ui compiler will automatically call this constructor.
  • This function declares a PageBar with a page count of zero, and you need to call the setCount method to set the page count.

The second method has three parameters:

QPageBar(int pageTotalCount, int pageShowCount = 5, QWidget* parent = nullptr);
  • This function declares a PageBar with a total page count of pageTotalCount and a display page button count of pageShowCount.

3. Implementing page switching

There are four ways to switch pages:

  • Click on the previous page button (<).
  • Click on the next page button (>).
  • Click on the page number button.
  • Enter the page number and click OK.

All four ways will activate the pageChanged signal, and the signal parameter int page is the page number to jump to. You only need to connect the pageChanged signal with the jump logic.

4. Other public methods are detailed in the code comments

3. Test program

There is a test program in the demo folder, which can be built using qmake. Simply open QPageBarDemo.pro with Qt Creator and compile and run it.

qpagebar's People

Contributors

hwdqm88 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.