QT乱翻书-Spin

技术QT乱翻书-Spin QT乱翻书-Spin跳转到大纲 码云QT乱翻书-Spin#ifndef WIDGET_H
#define WIDGET_H#include QWidgetnamespace U

夸脱乱翻书-旋转

跳转到大纲码云

QT乱翻书-Spin

#ifndef WIDGET_H

#定义WIDGET_H

#包含QWidget

命名空间Ui {

类小部件

}

类Widget :公共QWidget

{

Q_OBJECT

公众号:

显式widget(QWidget * parent=0);

~ Widget();

专用插槽3360

void on _ btnCal _ clicked();//计算按键已单击()响应

void on _ btnDec _ clicked();//读十进制数再用其他进制显示的按键的已单击()响应

void on _ btnBin _ clicked();//读二进制数再用其他进制显示的按键的已单击()响应

void on _ btnHex _ clicked();//读十六进制数再用其他进制显示的按键的已单击()响应

私人:

Ui:Widget * ui

};

#endif //WIDGET_H

/********************************************************************************

**通过读取用户界面文件widget.ui '生成表单

**

**由: Qt用户界面编译器5.9.1版创建

**

**警告!重新编译用户界面文件时,此文件中所做的所有更改都将丢失!

********************************************************************************/

#ifndef UI_WIDGET_H

#定义UI_WIDGET_H

#包含QtCore/QVariant

#包含QtWidgets/qaaction

#包含QtWidgets/qaapplication

#包含QtWidgets/QButtonGroup

#包含QtWidgets/QDoubleSpinBox

#包含QtWidgets/QGridLayout

#包含QtWidgets/QHeaderView

#包含QtWidgets/QLabel

#包含QtWidgets/qbutton

#包含QtWidgets/QSpacerItem

#包含QtWidgets/QSpinBox

#包含QtWidgets/QVBoxLayout

#包含QtWidgets/QWidget

QT _ BEgin _ NAME

类Ui_Widget

{

公众号:

QVBoxLayout *垂直布局;

QGridLayout * gridLayout

QLabel * label _ 3;

QDoubleSpinBox * spinTotal

QSpinBox * spinNum

QDoubleSpinBox * spinPrice

QLabel * label _ 2;

QLabel *标签;

QPushButton * btnCal

QSpacerItem *垂直空间

QGridLayout * gridLayout _ 2;

QLabel * label _ 6;

QLabel * label _ 7;

QPushButton * btnBin

QLabel * label _ 8;

QPushButton * btnDec

QPushButton * btnHex

qspace ritem * horizontalSpacer _ 2;

QSpinBox * spinDec

QSpinBox * spinBin

QSpinBox * spinHex

void setupUi(QWidget *Widget)

{

if (Widget-objectName().isEmpty())

Widget-setObjectName(QStringLiteral(' Widget '));

小部件-调整大小(303,172);

QFont字体;

字体。setfamily(来自utf8的qstring :3360(\ 345 \ 256 \ 213 \ 344 \ 275 \ 223’);

丰族

t.setPointSize(10);
Widget-setFont(font);
verticalLayout = new QVBoxLayout(Widget);
verticalLayout-setSpacing(6);
verticalLayout-setContentsMargins(11, 11, 11, 11);
verticalLayout-setObjectName(QStringLiteral("verticalLayout"));
gridLayout = new QGridLayout();
gridLayout-setSpacing(6);
gridLayout-setObjectName(QStringLiteral("gridLayout"));
label_3 = new QLabel(Widget);
label_3-setObjectName(QStringLiteral("label_3"));
label_3-setAlignment(Qt::AlignCenter);
gridLayout-addWidget(label_3, 1, 2, 1, 1);
spinTotal = new QDoubleSpinBox(Widget);
spinTotal-setObjectName(QStringLiteral("spinTotal"));
spinTotal-setMaximum(100000);
gridLayout-addWidget(spinTotal, 1, 3, 1, 1);
spinNum = new QSpinBox(Widget);
spinNum-setObjectName(QStringLiteral("spinNum"));
spinNum-setFrame(true);
spinNum-setButtonSymbols(QAbstractSpinBox::UpDownArrows);
spinNum-setProperty("showGroupSeparator", QVariant(false));
spinNum-setMaximum(1000);
spinNum-setValue(4);
gridLayout-addWidget(spinNum, 0, 1, 1, 1);
spinPrice = new QDoubleSpinBox(Widget);
spinPrice-setObjectName(QStringLiteral("spinPrice"));
spinPrice-setMinimumSize(QSize(90, 0));
spinPrice-setMaximum(10000);
spinPrice-setValue(12.43);
gridLayout-addWidget(spinPrice, 0, 3, 1, 1);
label_2 = new QLabel(Widget);
label_2-setObjectName(QStringLiteral("label_2"));
label_2-setAlignment(Qt::AlignCenter);
gridLayout-addWidget(label_2, 0, 2, 1, 1);
label = new QLabel(Widget);
label-setObjectName(QStringLiteral("label"));
label-setAlignment(Qt::AlignCenter);
gridLayout-addWidget(label, 0, 0, 1, 1);
btnCal = new QPushButton(Widget);
btnCal-setObjectName(QStringLiteral("btnCal"));
gridLayout-addWidget(btnCal, 1, 1, 1, 1);
verticalLayout-addLayout(gridLayout);
verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
verticalLayout-addItem(verticalSpacer);
gridLayout_2 = new QGridLayout();
gridLayout_2-setSpacing(6);
gridLayout_2-setObjectName(QStringLiteral("gridLayout_2"));
label_6 = new QLabel(Widget);
label_6-setObjectName(QStringLiteral("label_6"));
label_6-setMinimumSize(QSize(0, 0));
label_6-setAlignment(Qt::AlignCenter);
gridLayout_2-addWidget(label_6, 0, 0, 1, 1);
label_7 = new QLabel(Widget);
label_7-setObjectName(QStringLiteral("label_7"));
label_7-setAlignment(Qt::AlignCenter);
gridLayout_2-addWidget(label_7, 1, 0, 1, 1);
btnBin = new QPushButton(Widget);
btnBin-setObjectName(QStringLiteral("btnBin"));
gridLayout_2-addWidget(btnBin, 1, 3, 1, 1);
label_8 = new QLabel(Widget);
label_8-setObjectName(QStringLiteral("label_8"));
label_8-setAlignment(Qt::AlignCenter);
gridLayout_2-addWidget(label_8, 2, 0, 1, 1);
btnDec = new QPushButton(Widget);
btnDec-setObjectName(QStringLiteral("btnDec"));
gridLayout_2-addWidget(btnDec, 0, 3, 1, 1);
btnHex = new QPushButton(Widget);
btnHex-setObjectName(QStringLiteral("btnHex"));
gridLayout_2-addWidget(btnHex, 2, 3, 1, 1);
horizontalSpacer_2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
gridLayout_2-addItem(horizontalSpacer_2, 1, 2, 1, 1);
spinDec = new QSpinBox(Widget);
spinDec-setObjectName(QStringLiteral("spinDec"));
spinDec-setMinimumSize(QSize(100, 0));
spinDec-setMaximum(255);
spinDec-setValue(12);
gridLayout_2-addWidget(spinDec, 0, 1, 1, 1);
spinBin = new QSpinBox(Widget);
spinBin-setObjectName(QStringLiteral("spinBin"));
spinBin-setMaximum(255);
spinBin-setDisplayIntegerBase(2);
gridLayout_2-addWidget(spinBin, 1, 1, 1, 1);
spinHex = new QSpinBox(Widget);
spinHex-setObjectName(QStringLiteral("spinHex"));
spinHex-setMaximum(255);
spinHex-setValue(12);
spinHex-setDisplayIntegerBase(16);
gridLayout_2-addWidget(spinHex, 2, 1, 1, 1);
verticalLayout-addLayout(gridLayout_2);
retranslateUi(Widget);
QMetaObject::connectSlotsByName(Widget);
} // setupUi
void retranslateUi(QWidget *Widget)
{
Widget-setWindowTitle(QApplication::translate("Widget", "SpinBox\346\265\213\350\257\225", Q_NULLPTR));
label_3-setText(QApplication::translate("Widget", "\346\200\273 \344\273\267", Q_NULLPTR));
spinTotal-setPrefix(QApplication::translate("Widget", "$ ", Q_NULLPTR));
spinNum-setSuffix(QApplication::translate("Widget", " kg", Q_NULLPTR));
spinPrice-setPrefix(QApplication::translate("Widget", "$ ", Q_NULLPTR));
label_2-setText(QApplication::translate("Widget", "\345\215\225 \344\273\267", Q_NULLPTR));
label-setText(QApplication::translate("Widget", "\346\225\260 \351\207\217", Q_NULLPTR));
btnCal-setText(QApplication::translate("Widget", "\350\256\241\347\256\227", Q_NULLPTR));
label_6-setText(QApplication::translate("Widget", "\345\215\201 \350\277\233 \345\210\266", Q_NULLPTR));
label_7-setText(QApplication::translate("Widget", "\344\272\214 \350\277\233 \345\210\266", Q_NULLPTR));
btnBin-setText(QApplication::translate("Widget", "\350\275\254\346\215\242\344\270\272\345\205\266\344\273\226\350\277\233\345\210\266", Q_NULLPTR));
label_8-setText(QApplication::translate("Widget", "\345\215\201\345\205\255\350\277\233\345\210\266", Q_NULLPTR));
btnDec-setText(QApplication::translate("Widget", "\350\275\254\346\215\242\344\270\272\345\205\266\344\273\226\350\277\233\345\210\266", Q_NULLPTR));
btnHex-setText(QApplication::translate("Widget", "\350\275\254\346\215\242\344\270\272\345\205\266\344\273\226\350\277\233\345\210\266", Q_NULLPTR));
spinDec-setSuffix(QString());
spinDec-setPrefix(QApplication::translate("Widget", "Dec ", Q_NULLPTR));
spinBin-setPrefix(QApplication::translate("Widget", "Bin ", Q_NULLPTR));
spinHex-setPrefix(QApplication::translate("Widget", "Hex ", Q_NULLPTR));
} // retranslateUi
};
namespace Ui {
class Widget: public Ui_Widget {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_WIDGET_H

#include "widget.h"
#include QApplication
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.show();
    return a.exec();
}
#include    "widget.h"
#include    "ui_widget.h"
#include    QString
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui-setupUi(this);
//“数量”和“单价”两个SpinBox的valueChanged()信号与on_btnCal_clicked()槽关联
    QObject::connect(ui-spinNum,SIGNAL(valueChanged(int)),this,SLOT(on_btnCal_clicked()));  //
    QObject::connect(ui-spinPrice,SIGNAL(valueChanged(double)),this,SLOT(on_btnCal_clicked()));
    QObject::connect(ui-spinDec,SIGNAL(valueChanged(int)),
                     this,SLOT(on_btnDec_clicked()));//spinDec 十进制显示的SpinBox
    QObject::connect(ui-spinBin,SIGNAL(valueChanged(int)),
                     this,SLOT(on_btnBin_clicked()));//spinBin 二进制显示的SpinBox
    QObject::connect(ui-spinHex,SIGNAL(valueChanged(int)),
                     this,SLOT(on_btnHex_clicked()));//spinHex 十六进制显示的SpinBox
}
Widget::~Widget()
{
    delete ui;
}
void Widget::on_btnCal_clicked()
{ //计算按键
    int num=ui-spinNum-value(); //读取数量,直接是整数
    float price=ui-spinPrice-value();//读取单价,直接是浮点数
    float total=num*price;//相乘计算
    ui-spinTotal-setValue(total); //直接显示浮点数
}
void Widget::on_btnDec_clicked()
{ //读取十进制,以其他进制显示
    int val;
    val=ui-spinDec-value();//读取十进制数
    ui-spinBin-setValue(val); //设置数值即可,自动以二进制显示
    ui-spinHex-setValue(val); //设置数值即可,自动以十六进制显示
}
void Widget::on_btnBin_clicked()
{ //读取二进制,以其他进制显示
    int val=ui-spinBin-value();//读取spinBin里的二进制数,得到整数
    ui-spinDec-setValue(val);//设置数值即可,自动以十进制显示
    ui-spinHex-setValue(val);//设置数值即可,自动以十六进制显示
}
void Widget::on_btnHex_clicked()
{ //读取十六进制,以其他进制显示
    int val;
    val=ui-spinHex-value();//读取 spinHex 里的十六进制数,得到整数
    ui-spinDec-setValue(val);//设置数值即可,自动以十进制显示
    ui-spinBin-setValue(val);//设置数值即可,自动以二进制显示
}
xml version="1.0" encoding="UTF-8"
ui version="4.0"
 classWidget/class
 widget class="QWidget" name="Widget"
  property name="geometry"
   rect
    x0/x
    y0/y
    width442/width
    height238/height
   /rect
  /property
  property name="font"
   font
    family宋体/family
    pointsize10/pointsize
   /font
  /property
  property name="windowTitle"
   stringSpinBox测试/string
  /property
  layout class="QVBoxLayout" name="verticalLayout"
   item
    layout class="QGridLayout" name="gridLayout"
     item row="1" column="2"
      widget class="QLabel" name="label_3"
       property name="text"
        string总 价/string
       /property
       property name="alignment"
        setQt::AlignCenter/set
       /property
      /widget
     /item
     item row="1" column="3"
      widget class="QDoubleSpinBox" name="spinTotal"
       property name="prefix"
        string$ /string
       /property
       property name="maximum"
        double100000.000000000000000/double
       /property
      /widget
     /item
     item row="0" column="1"
      widget class="QSpinBox" name="spinNum"
       property name="frame"
        booltrue/bool
       /property
       property name="buttonSymbols"
        enumQAbstractSpinBox::UpDownArrows/enum
       /property
       property name="showGroupSeparator" stdset="0"
        boolfalse/bool
       /property
       property name="suffix"
        string kg/string
       /property
       property name="maximum"
        number1000/number
       /property
       property name="value"
        number4/number
       /property
      /widget
     /item
     item row="0" column="3"
      widget class="QDoubleSpinBox" name="spinPrice"
       property name="minimumSize"
        size
         width90/width
         height0/height
        /size
       /property
       property name="prefix"
        string$ /string
       /property
       property name="maximum"
        double10000.000000000000000/double
       /property
       property name="value"
        double12.430000000000000/double
       /property
      /widget
     /item
     item row="0" column="2"
      widget class="QLabel" name="label_2"
       property name="text"
        string单 价/string
       /property
       property name="alignment"
        setQt::AlignCenter/set
       /property
      /widget
     /item
     item row="0" column="0"
      widget class="QLabel" name="label"
       property name="text"
        string数 量/string
       /property
       property name="alignment"
        setQt::AlignCenter/set
       /property
      /widget
     /item
     item row="1" column="1"
      widget class="QPushButton" name="btnCal"
       property name="text"
        string计算/string
       /property
      /widget
     /item
    /layout
   /item
   item
    spacer name="verticalSpacer"
     property name="orientation"
      enumQt::Vertical/enum
     /property
     property name="sizeHint" stdset="0"
      size
       width20/width
       height40/height
      /size
     /property
    /spacer
   /item
   item
    layout class="QGridLayout" name="gridLayout_2"
     item row="0" column="0"
      widget class="QLabel" name="label_6"
       property name="minimumSize"
        size
         width0/width
         height0/height
        /size
       /property
       property name="text"
        string十 进 制/string
       /property
       property name="alignment"
        setQt::AlignCenter/set
       /property
      /widget
     /item
     item row="1" column="0"
      widget class="QLabel" name="label_7"
       property name="text"
        string二 进 制/string
       /property
       property name="alignment"
        setQt::AlignCenter/set
       /property
      /widget
     /item
     item row="1" column="3"
      widget class="QPushButton" name="btnBin"
       property name="text"
        string转换为其他进制/string
       /property
      /widget
     /item
     item row="2" column="0"
      widget class="QLabel" name="label_8"
       property name="text"
        string十六进制/string
       /property
       property name="alignment"
        setQt::AlignCenter/set
       /property
      /widget
     /item
     item row="0" column="3"
      widget class="QPushButton" name="btnDec"
       property name="text"
        string转换为其他进制/string
       /property
      /widget
     /item
     item row="2" column="3"
      widget class="QPushButton" name="btnHex"
       property name="text"
        string转换为其他进制/string
       /property
      /widget
     /item
     item row="1" column="2"
      spacer name="horizontalSpacer_2"
       property name="orientation"
        enumQt::Horizontal/enum
       /property
       property name="sizeHint" stdset="0"
        size
         width40/width
         height20/height
        /size
       /property
      /spacer
     /item
     item row="0" column="1"
      widget class="QSpinBox" name="spinDec"
       property name="minimumSize"
        size
         width100/width
         height0/height
        /size
       /property
       property name="suffix"
        string/
       /property
       property name="prefix"
        stringDec /string
       /property
       property name="maximum"
        number255/number
       /property
       property name="value"
        number12/number
       /property
      /widget
     /item
     item row="1" column="1"
      widget class="QSpinBox" name="spinBin"
       property name="prefix"
        stringBin /string
       /property
       property name="maximum"
        number255/number
       /property
       property name="displayIntegerBase"
        number2/number
       /property
      /widget
     /item
     item row="2" column="1"
      widget class="QSpinBox" name="spinHex"
       property name="prefix"
        stringHex /string
       /property
       property name="maximum"
        number255/number
       /property
       property name="value"
        number12/number
       /property
       property name="displayIntegerBase"
        number16/number
       /property
      /widget
     /item
    /layout
   /item
  /layout
 /widget
 layoutdefault spacing="6" margin="11"/
 resources/
 connections/
/ui

内容来源网络,如有侵权,联系删除,本文地址:https://www.230890.com/zhan/145045.html

(0)

相关推荐

  • 如何用php删除本地文件

    技术如何用php删除本地文件这篇文章主要介绍“如何用php删除本地文件”,在日常操作中,相信很多人在如何用php删除本地文件问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”如何用php删除本

    攻略 2021年10月29日
  • div鼠标放上去就放大用css3怎么写(css3实现div放大)

    技术css3如何实现div放大这篇文章主要讲解了“css3如何实现div放大”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“css3如何实现div放大”吧!

    攻略 2021年12月15日
  • c++面试题(c++用什么软件编程)

    技术如何利用上下文属性将 C++ 对象嵌入 QML 里本篇文章为大家展示了如何利用上下文属性将 C++ 对象嵌入 QML 里,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。一、设置

    攻略 2021年12月15日
  • java中抽象类和接口的区别(java接口和抽象类有什么不同)

    技术java中抽象类和接口的相同和不同点是什么这篇文章将为大家详细讲解有关java中抽象类和接口的相同和不同点是什么,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。前言下面

    攻略 2021年12月20日
  • leetcode排序链表怎么用(leetcode单链表反转)

    技术LeetCode如何k个一组翻转链表这篇文章给大家分享的是有关LeetCode如何k个一组翻转链表的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。 题目描述:给你一个链表,每 k 个节点一组

    攻略 2021年12月15日
  • 用jquery制作最简单登录功能(jquery中能够编辑html内容的方法)

    技术HTML+jQuery如何实现简单的登录页面这篇文章主要介绍“HTML+jQuery如何实现简单的登录页面”,在日常操作中,相信很多人在HTML+jQuery如何实现简单的登录页面问题上存在疑惑,小编查阅了各式资料,

    攻略 2021年12月13日