-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmainwindow.cpp
41 lines (30 loc) · 1.15 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "mainwindow.h"
#include "qpagination.h"
#include "ui_mainwindow.h"
#include <QHBoxLayout>
#include <QLabel>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow) {
ui->setupUi(this);
QWidget *widget = new QWidget(this);
widget->setGeometry(0, 0, 560, 50);
QHBoxLayout *hbox = new QHBoxLayout(widget);
setCentralWidget(widget);
QPagination *pagination = new QPagination(widget);
hbox->addWidget(pagination);
QLabel *label = new QLabel(this);
label->setText(QString::number(pagination->getCurrentPage()));
connect(pagination, &QPagination::onPageChange, [=](int value) {
label->setText(QString::number(value));
});
pagination->setStyleSheet("QPushButton { margin: 0 2px; color: #000; background: #fff; border: 1px solid #f00; border-radius: 5px; } QPushButton:disabled { background: #ccc; } QPushButton:hover { background:transparent; }");
pagination->setTotalPages(20);
pagination->setCurrentPage(17);
pagination->setButtonsSize(QSize(30, 30));
pagination->show();
pagination->updateTotalPages(10);
}
MainWindow::~MainWindow() {
delete ui;
}