QT5-控件-QSpinBox和QDoubleSpinBox(用于通过控件调整整数和小数)

#ifndef MAINWINDOW_H
#define MAINWINDOW_H #include <QMainWindow>
#include <QSpinBox>
#include <QDoubleSpinBox> class MainWindow : public QMainWindow
{
Q_OBJECT public:
MainWindow(QWidget *parent = );
~MainWindow(); QSpinBox* spin[];
QDoubleSpinBox* doublespin[];
}; #endif // MAINWINDOW_H
#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
this->resize(,);
this->centralWidget(); int xpos = ;
int ypos = ; int val[] = {,,};
double double_val[] = {50.5,127.32,171.342}; for(int i=;i<;i++)
{
spin[i] = new QSpinBox(this);
spin[i]->setMinimum();
spin[i]->setMaximum();
spin[i]->setValue(val[i]);
spin[i]->setGeometry(xpos,ypos,,);
spin[i]->setPrefix("$ "); doublespin[i] = new QDoubleSpinBox(this);
doublespin[i]->setMinimum(10.0);
doublespin[i]->setMaximum(300.0);
doublespin[i]->setValue(double_val[i]);
doublespin[i]->setGeometry(xpos+,ypos,,);
doublespin[i]->setSuffix(" mm"); ypos += ;
}
} MainWindow::~MainWindow()
{ }
#include "mainwindow.h"
#include <QApplication> int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show(); return a.exec();
}

QT5-控件-QSpinBox和QDoubleSpinBox(用于通过控件调整整数和小数)

上一篇:一年后重翻javascript


下一篇:10gRAC运行srvctl报错error while loading shared libraries: