mainWindows spinBox decleration
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 4.15.0, 2021-05-22T22:51:04. -->
|
<!-- Written by QtCreator 4.15.0, 2021-05-24T12:12:52. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
@ -11,5 +11,23 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
|
spinBase = ui->spinBase;
|
||||||
|
spinExp = ui->spinExp;
|
||||||
|
spinMod = ui->spinMod;
|
||||||
|
|
||||||
|
connect(spinBase, SIGNAL(valueChanged(int)), this, SLOT(SetModel()));
|
||||||
|
connect(spinExp, SIGNAL(valueChanged(int)), this, SLOT(SetModel()));
|
||||||
|
connect(spinMod, SIGNAL(valueChanged(int)), this, SLOT(SetModel()));
|
||||||
|
|
||||||
|
resultTable = ui->resultTable;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::SetModel() {
|
||||||
|
int base = spinBase->value();
|
||||||
|
int exp = spinExp->value();
|
||||||
|
int mod = spinMod->value();
|
||||||
|
|
||||||
|
resultTableModel->SetStartValues(base, exp, mod);
|
||||||
|
resultTable->setModel(resultTableModel);
|
||||||
|
}
|
||||||
|
@ -2,6 +2,11 @@
|
|||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include "sqmtablemodel.h"
|
||||||
|
|
||||||
|
class SQMTableModel;
|
||||||
|
class QSpinBox;
|
||||||
|
class QTableView;
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
@ -15,7 +20,14 @@ public:
|
|||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void SetModel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
QSpinBox *spinBase, *spinExp, *spinMod;
|
||||||
|
QTableView *resultTable;
|
||||||
|
SQMTableModel *resultTableModel;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
@ -6,15 +6,77 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>390</width>
|
||||||
<height>600</height>
|
<height>562</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>MainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget"/>
|
<widget class="QWidget" name="centralwidget">
|
||||||
<widget class="QMenuBar" name="menubar"/>
|
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>371</width>
|
||||||
|
<height>71</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labBase">
|
||||||
|
<property name="text">
|
||||||
|
<string>Base:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="spinBase"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labExp">
|
||||||
|
<property name="text">
|
||||||
|
<string>Exponent:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="spinExp"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labMod">
|
||||||
|
<property name="text">
|
||||||
|
<string>Modulus:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="spinMod"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QTableView" name="resultTable">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>90</y>
|
||||||
|
<width>371</width>
|
||||||
|
<height>421</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenuBar" name="menubar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>390</width>
|
||||||
|
<height>20</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -5,6 +5,16 @@ SQMTableModel::SQMTableModel(QObject *parent)
|
|||||||
: QAbstractTableModel(parent) {
|
: QAbstractTableModel(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int SQMTableModel::rowCount(const QModelIndex & parent) const {
|
||||||
|
return binLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SQMTableModel::columnCount(const QModelIndex & parent) const {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariant SQMTableModel::data(const QModelIndex &index, int role) const {
|
QVariant SQMTableModel::data(const QModelIndex &index, int role) const {
|
||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
@ -16,6 +26,7 @@ QVariant SQMTableModel::data(const QModelIndex &index, int role) const {
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SQMTableModel::SetStartValues(int pBase, int pExp, int pMod) {
|
void SQMTableModel::SetStartValues(int pBase, int pExp, int pMod) {
|
||||||
base = pBase;
|
base = pBase;
|
||||||
exp = pExp;
|
exp = pExp;
|
||||||
@ -37,7 +48,7 @@ std::string SQMTableModel::IntToBinary(int n) {
|
|||||||
|
|
||||||
void SQMTableModel::CalculateSqmMatrix(int startRow) {
|
void SQMTableModel::CalculateSqmMatrix(int startRow) {
|
||||||
string bin = IntToBinary(exp);
|
string bin = IntToBinary(exp);
|
||||||
int binLen = bin.length();
|
binLen = bin.length();
|
||||||
|
|
||||||
// Initialize bin column
|
// Initialize bin column
|
||||||
vector<int> colBin;
|
vector<int> colBin;
|
||||||
|
@ -9,6 +9,8 @@ class SQMTableModel : public QAbstractTableModel {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
SQMTableModel(QObject *parent = nullptr);
|
SQMTableModel(QObject *parent = nullptr);
|
||||||
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
|
|
||||||
void SetStartValues(int pBase, int pExp, int pMod);
|
void SetStartValues(int pBase, int pExp, int pMod);
|
||||||
@ -20,6 +22,7 @@ private:
|
|||||||
int base;
|
int base;
|
||||||
int exp;
|
int exp;
|
||||||
int mod;
|
int mod;
|
||||||
|
int binLen;
|
||||||
|
|
||||||
vector<vector <int>> sqmMatrix;
|
vector<vector <int>> sqmMatrix;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user