Qt实现的计算器

2023-05-16

写在前边:这篇文章只是来带着大家一起实现一个基于Qt的计算器。中间会出现很多概念,我们不做拓展介绍,大家只要知道怎么用就好,如果有需要我们后续再详细的对每个模块解析。

1.首先介绍一下Qt,尽管大家再明白不过了。Qt是一个1991年由Qt Company开发的跨平台C++图形用户界面应用程序开发框架。它既可以开发GUI程序,也可用于开发非GUI程序,比如控制台工具和服务器。是一个面向对象的框架。由于其良好的跨平台性以及适当的封装,使得它成为很多C++程序员(当然,QT发展到现在已经是一个很完备的IDE,支持java以及安卓等)写界面的首选。

2.signal&slot机制。也就是Qt独创的信号和槽的机制。这种机制其实在现在是很常用的,但是现在很多用来完成界面的语言已经把这一机制封装的十分简洁,用起来就十分的方便。至于这个机制的作用我们就不再详解,这个机制的作用我们就不再继续的深入讨论了,现在我们只需要知道的就是他是用来给按钮添加事件的。什么?什么叫做给按钮添加时间?给按钮添加时间值得是点击按钮要做的事情,比如说我们点击删除按钮,就会删除文件,就是这个意思。

3.信号的槽的实现原理:connect函数/直接转到槽函数。很多同学上来就是无法理解什么叫做槽什么叫做信号。槽其实很简单,槽就是函数。而且是一类很特殊的函数,之所以说它特殊,是因为它的很多东西都是固定的:它的功能就是为了处理对应的信号,它的返回类型就是void,它只能被这样声明:public slots/private slots/protected/slots。信号就是按钮的想要说的话,例如,我们假如有一个按钮被点击,他就会发射一个我被点击了的信号,这个信号被槽接收,槽也就是这个函数做出处理,例如,如果这个槽接收到被点击的信号他可能会说一句话:哪个胆子大的敢点击你,老子去安排他。然而,这个槽该如何接收信号呢?信号发射出去但是槽接收不到啊,这个时候connect就出现了。connect函数是将信号和槽链接起来的一个重要的中间支持。connect有四个参数我们给出这个函数调用时的一般形式:connect(a,b,c,d)。这四个参数的意义也是很好记的,第一个是信号发射的对象,第二个是信号的类型,第三个是当前接收信号的对象,第四个是对象的槽函数,也就是槽。没看懂?OK我们来个栗子解释一下:

connect(ui->first,SIGNAL(clicked(bool)),this,SLOT(button_1_clicked()));对于这个connect我们来详细的解释一下。

首先是第一个参数,说明我们的UI文件里面有一个叫做first的按钮,第二个参数说明这个按钮发射出来的信号是被点击(注意:这里的信号是系统的内置信号,就是说不用你自己定义,直接抄上去就可以用的。当然也可以自定义按钮的信号,这里我们就不在深入的探讨了,这里用不到)。第三个参数我们也不用管,直接写上this就好,它表示当前对象接收信号,第四个就是我们的槽函数了。这个函数是由我们自己定义的一个函数。这样就可以完成了按钮和它对应的处理函数的链接了。当然了,这看起来可能有点复杂,也有一种简单的方法,就是在可视化布局的时候布局按钮的时候我们可以直接找到这个按钮的属性,然后转到槽,这样即使不使用connect也是可以的。

有了上面的知识我们就来实现一下计算器。我们首先分析一下这个问题:我们需要在输入框中获取当前用户输入的字符串,然后再设计函数实现对这个字符串的计算之后再输出到文本显示框。那么其实我们程序的模块已经很清楚了:数据获取&数据处理。  4.数据获取的实现:这个模块要求我们实时的将按钮点击对应的字符加到原字符串上并显示出来,那么我们首先需要一个字符串,这个字符串被所有的函数共享,所以我们把它定义为类的一个私有的成员变量。我们来具体分析一个:如果我点击代表数字1的按钮,那么当前字符串就需要加上1,也就是执行s+="1",之后再显示到文本框内。也就是set这个文本框内的值。然后对每个按钮做这样的映射,就可以完成表达式的显示。

5.获取完字符串之后,我们需要定义相应的处理函数计算表达式的值。这是一个经典的算法问题,中缀表达式的计算,常用的方法就是首先转为后缀表达式然后再计算后缀表达式,这会使用一种数据结构:栈。这个算法的实现我就不再详细的说了,现在VS里面把算法弄好再移植到Qt,因为VS调试功能十分强大,要是在QT里面直接写,会出现很多难受的错误,又不好调试。

6.ui文件的设计,大佬们都是不需要可视化的操作的,他们都是直接写代码来完成界面的设计,而我还是需要来回的拖控件,布局界面。ui文件的设计是一个很重要的模块,建议给每一个控件一个名字,这个名字可以反映它的功能,并且具有相同的命名规则,例如首字母大写啊什么的,这会在写后台的处理函数,也就是槽函数的时候带来很大的帮助,因为你不用一直去翻UI来看这个控件的名称。我的UI就不附上了,大家可以在connect函数中看到每个控件的名称,我会把这个界面的XML文件附上。

7.具体代码:

.h:

#ifndef CAL_H

#define CAL_H

#include<QString>

#include <QMainWindow>

#include<QStringList>

namespace Ui {

class cal;

}


 

class cal : public QMainWindow

{

    Q_OBJECT


 

public:

    explicit cal(QWidget *parent = 0);

    ~cal();

private:

    QString s;

    Ui::cal *ui;

private slots:

    void button_0_clicked();

    void button_1_clicked();

    void button_2_clicked();

    void button_3_clicked();

    void button_4_clicked();

    void button_5_clicked();

    void button_6_clicked();

    void button_7_clicked();

    void button_8_clicked();

    void button_9_clicked();

    void button_ac_clicked();

    void button_result_clicked();

    void button_mul_clicked();

    void button_devide_clicked();

    void button_add_clicked();

    void button_sub_clicked();

    void button_sin_clicked();

    void button_cos_clicked();

    void button_tan_clicked();

    void button_sqrt_clicked();

    void button_pow_clicked();

    void button_ln_clicked();

    void button_log_clicked();

    void button_point_clicked();

    void button_mod_clicked();

    void button_AC_clicked();

    void button_left_clicked();

    void button_right_clicked();

    void Cal5();

private:

     QByteArray Cal2();

    double Cal3(double a,char op,double b);

    double Cal4(char op,double a);

    QStringList stackChange;

    QStringList calculateProcess;

    bool flag;

    bool buttonFlag;

    int pri[256];

    bool one[256];

};

#endif // CAL_H

.cpp:

#include "cal.h"

#include "ui_cal.h"

#include<QString>

#include<QStack>

#include<QDebug>

#include<QColor>

#include<QMap>

#include<QByteArray>

#include<qmath.h>

cal::cal(QWidget *parent) :

    QMainWindow(parent),

    ui(new Ui::cal)

{

    ui->setupUi(this);

    connect(ui->first,SIGNAL(clicked(bool)),this,SLOT(button_1_clicked()));

    connect(ui->zero,SIGNAL(clicked(bool)),this,SLOT(button_0_clicked()));

    connect(ui->second,SIGNAL(clicked(bool)),this,SLOT(button_2_clicked()));

    connect(ui->third,SIGNAL(clicked(bool)),this,SLOT(button_3_clicked()));

    connect(ui->four,SIGNAL(clicked(bool)),this,SLOT(button_4_clicked()));

    connect(ui->five,SIGNAL(clicked(bool)),this,SLOT(button_5_clicked()));

    connect(ui->six,SIGNAL(clicked(bool)),this,SLOT(button_6_clicked()));

    connect(ui->seven,SIGNAL(clicked(bool)),this,SLOT(button_7_clicked()));

    connect(ui->eight,SIGNAL(clicked(bool)),this,SLOT(button_8_clicked()));

    connect(ui->nine,SIGNAL(clicked(bool)),this,SLOT(button_9_clicked()));

    connect(ui->add,SIGNAL(clicked(bool)),this,SLOT(button_add_clicked()));

    connect(ui->sub,SIGNAL(clicked(bool)),this,SLOT(button_sub_clicked()));

    connect(ui->mul,SIGNAL(clicked(bool)),this,SLOT(button_mul_clicked()));

    connect(ui->Divide,SIGNAL(clicked(bool)),this,SLOT(button_devide_clicked()));

    connect(ui->Delete,SIGNAL(clicked(bool)),this,SLOT(button_ac_clicked()));

   // connect(ui->Cal,SIGNAL(clicked(bool)),this,SLOT(button_result_clicked()));

    connect(ui->sin,SIGNAL(clicked(bool)),this,SLOT(button_sin_clicked()));

    connect(ui->cos,SIGNAL(clicked(bool)),this,SLOT(button_cos_clicked()));

    connect(ui->tan,SIGNAL(clicked(bool)),this,SLOT(button_tan_clicked()));

   // connect(ui->ln,SIGNAL(clicked(bool)),this,SLOT(button_ln_clicked()));

    connect(ui->log,SIGNAL(clicked(bool)),this,SLOT(button_log_clicked()));

    connect(ui->pow,SIGNAL(clicked(bool)),this,SLOT(button_pow_clicked()));

    //connect(ui->Cal,SIGNAL(clicked(bool)),this,SLOT(Cal()));

    connect(ui->point,SIGNAL(clicked(bool)),this,SLOT(button_point_clicked()));

    connect(ui->AC,SIGNAL(clicked(bool)),this,SLOT(button_AC_clicked()));

    connect(ui->left,SIGNAL(clicked(bool)),this,SLOT(button_left_clicked()));

    connect(ui->right,SIGNAL(clicked(bool)),this,SLOT(button_right_clicked()));

    connect(ui->Cal,SIGNAL(clicked(bool)),this,SLOT(Cal5()));

    connect(ui->sqrt,SIGNAL(clicked(bool)),this,SLOT(button_sqrt_clicked()));

    connect(ui->mod,SIGNAL(clicked(bool)),this,SLOT(button_mod_clicked()));

    connect(ui->ln,SIGNAL(clicked(bool)),this,SLOT(button_ln_clicked()));

    QPalette pal = this->palette();

    pal.setColor(QPalette::Window,QColor(120,120,120));

    this->setPalette(pal);

    ui->lineEdit->setPalette(pal);

    ui->lineEdit->setStyleSheet("font-size:40px;border-width:0;");

    ui->lineEdit->setAlignment(Qt::AlignRight);

}

cal::~cal()

{

    delete ui;

}

void cal::button_0_clicked()

{

    s+="0";

    ui->lineEdit->setText(s);

}

void cal::button_1_clicked()

{

    s+="1";

    ui->lineEdit->setText(s);

}

void cal::button_2_clicked()

{

    s+="2";

    ui->lineEdit->setText(s);

}

void cal::button_3_clicked()

{

    s+="3";

    ui->lineEdit->setText(s);

}

void cal::button_4_clicked()

{

    s+="4";

    ui->lineEdit->setText(s);

}

void cal::button_5_clicked()

{

    s+="5";

    ui->lineEdit->setText(s);

}

void cal::button_6_clicked()

{

    s+="6";

    ui->lineEdit->setText(s);

}

void cal::button_7_clicked()

{

    s+="7";

    ui->lineEdit->setText(s);

}

void cal::button_8_clicked()

{

    s+="8";

    ui->lineEdit->setText(s);

}

void cal::button_9_clicked()

{

    s+="9";

    ui->lineEdit->setText(s);

}

void cal::button_add_clicked()

{

    s+="+";

    ui->lineEdit->setText(s);

}

void cal::button_sub_clicked()

{

    s+="-";

    ui->lineEdit->setText(s);

}

void cal::button_mul_clicked()

{

    s+="*";

    ui->lineEdit->setText(s);

}

void cal::button_devide_clicked()

{

    s+="/";

    ui->lineEdit->setText(s);

}

void cal::button_result_clicked()

{

   ui->lineEdit->setText(s);

}

void cal::button_ac_clicked()

{

    s="";

    ui->lineEdit->setText(s);

}

void cal::button_sin_clicked()

{

  s+="sin";

  ui->lineEdit->setText(s);

}

void cal::button_cos_clicked()

{


 

    s+="cos";

    ui->lineEdit->setText(s);

}

void cal::button_tan_clicked()

{


 

    s="tan";

    ui->lineEdit->setText(s);

}

void cal::button_sqrt_clicked()

{


 

    s+="Sqrt";

    ui->lineEdit->setText(s);

}

void cal::button_pow_clicked()

{


 

    s+="^";

    ui->lineEdit->setText(s);

}

void cal::button_log_clicked()

{


 

    s+="log";

    ui->lineEdit->setText(s);

}

void cal::button_ln_clicked()

{

    s+="ln";

    ui->lineEdit->setText(s);

}

void cal::button_point_clicked()

{

    s+=".";

    ui->lineEdit->setText(s);

}

void cal::button_left_clicked()

{

    s+="(";

    ui->lineEdit->setText(s);

}

void cal::button_right_clicked()

{

    s+=")";

    ui->lineEdit->setText(s);

}

void cal::button_mod_clicked()

{

    s+="%";

    ui->lineEdit->setText(s);

}


 

void cal::button_AC_clicked()

{

    ui->lineEdit->backspace();

}

QByteArray cal::Cal2()

{


 

    pri['+']=1;one['+']=false;

    pri['-']=1;one['-']=false;

    pri['*']=2;one['*']=false;

    pri['/']=2;one['/']=false;

    pri['%']=2;one['%']=false;

    pri['^']=3;one['^']=false;

    pri['@']=3;one['@']=true;

    pri['s']=3;one['s']=true;

    pri['c']=3;one['c']=true;

    pri['t']=3;one['t']=true;

    pri['l']=3;one['l']=true;

    pri['p']=3;one['p']=true;

    pri['S']=3;one['S']=true;

    pri['L']=3;one['L']=true;

    QString in2=this->s;

    QByteArray in=in2.toLocal8Bit();

    QByteArray out;

        QStack<char>op;

        for(int i=0;i<in.size();i++)

        {

            if(in[i]>='0'&&in[i]<='9')out.push_back(in[i]);

            else if(in[i]=='(')op.push(in[i]);

            else if(in[i]==')')

            {

                while(op.top()!='(')

                {

                    out.push_back(op.top());

                    op.pop();

                }

                op.pop();

            }

            else if(one[in[i]]||(in[i]=='-'&&(i==0||!isdigit(in[i-1]))))

            {

                if(in[i]=='-')

                {

                    op.push('@');

                }

                else if(in[i]=='s')

                    {

                        op.push('s');

                        i+=2;

                    }

                 else if(in[i]=='c')

                    {

                        op.push('c');

                        i+=2;

                    }

                 else if(in[i]=='t')

                    {

                        op.push('t');

                        i+=2;

                    }

                 else if(in[i]=='l')

                    {

                        op.push('l');

                        i++;

                    }

                 else if(in[i]=='S')

                    {

                        op.push('S');

                        i+=3;

                    }

                else if(in[i]=='L')

                {

                    op.push('L');

                    i+=2;

                }

                else op.push(in[i]);

            }

           else

            {

                while((!op.empty())&&pri[op.top()]>=pri[in[i]])

                {

                    //操作符栈内优先级高

                    out.push_back(op.top());

                    op.pop();

                }

                op.push(in[i]);

            }

        }

        while(!op.empty())

        {

            out.push_back(op.top());

            op.pop();

        }


 

      return out;

}

double cal::Cal3(double a, char op, double b)

{

    switch (op){

        case '+':return a+b;

        case '-':return a-b;

        case '*':return a*b;

        case '/':return a/b;

        case '%':return (int)a%(int)b;

        case '^':return qPow(a,b);

    }

}

double cal::Cal4(char op, double a)

{

     if(op=='@')return -a;

     else if(op=='s')return qSin(a);

     else if(op=='c')return qCos(a);

     else if(op=='t')return qTan(a);

     else if(op=='S')return qSqrt(a);

     else if(op=='l')return qLn(a);

     else if(op=='L') return (qLn(a)/qLn(10));

}

void cal::Cal5()

{


 

        QByteArray in=this->Cal2();

        QStack<double>num;

        for(int i=0;i<in.size();i++){

            if(in[i]>='0'&&in[i]<='9')num.push(in[i]-'0');

            else if(one[in[i]]){

                double a=num.top();num.pop();

                num.push(Cal4(in[i],a));

            }else{

                double a=num.top();num.pop();

                double b=num.top();num.pop();

                num.push(Cal3(b,in[i],a));

            }

        }

        double a=num.top();

        QString tem=QString::number(a,10,5);

        ui->lineEdit->setText(tem);

}
main函数:

#include "cal.h"

#include <QApplication>

int main(int argc, char *argv[])

{

    QApplication a(argc, argv);

    cal w;

    w.show();

    return a.exec();

}

XML文件:

<?xml version="1.0" encoding="UTF-8"?>

<ui version="4.0">

 <class>cal</class>

 <widget class="QMainWindow" name="cal">

  <property name="geometry">

   <rect>

    <x>0</x>

    <y>0</y>

    <width>352</width>

    <height>464</height>

   </rect>

  </property>

  <property name="windowTitle">

   <string>cal</string>

  </property>

  <widget class="QWidget" name="centralWidget">

   <widget class="QLineEdit" name="lineEdit">

    <property name="geometry">

     <rect>

      <x>10</x>

      <y>0</y>

      <width>321</width>

      <height>41</height>

     </rect>

    </property>

    <property name="text">

     <string>0.00</string>

    </property>

   </widget>

   <widget class="QPushButton" name="mod">

    <property name="geometry">

     <rect>

      <x>11</x>

      <y>46</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>%</string>

    </property>

   </widget>

   <widget class="QPushButton" name="sqrt">

    <property name="geometry">

     <rect>

      <x>96</x>

      <y>46</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>Sqrt</string>

    </property>

   </widget>

   <widget class="QPushButton" name="left">

    <property name="geometry">

     <rect>

      <x>266</x>

      <y>46</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>(</string>

    </property>

   </widget>

   <widget class="QPushButton" name="pow">

    <property name="geometry">

     <rect>

      <x>181</x>

      <y>46</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>^</string>

    </property>

   </widget>

   <widget class="QPushButton" name="right">

    <property name="geometry">

     <rect>

      <x>11</x>

      <y>99</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>)</string>

    </property>

   </widget>

   <widget class="QPushButton" name="AC">

    <property name="geometry">

     <rect>

      <x>96</x>

      <y>99</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>AC</string>

    </property>

   </widget>

   <widget class="QPushButton" name="Delete">

    <property name="geometry">

     <rect>

      <x>181</x>

      <y>99</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>CLEAR</string>

    </property>

   </widget>

   <widget class="QPushButton" name="Divide">

    <property name="geometry">

     <rect>

      <x>266</x>

      <y>99</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>/</string>

    </property>

    <property name="iconSize">

     <size>

      <width>20</width>

      <height>40</height>

     </size>

    </property>

    <property name="autoRepeatInterval">

     <number>200</number>

    </property>

   </widget>

   <widget class="QPushButton" name="second">

    <property name="geometry">

     <rect>

      <x>96</x>

      <y>152</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>2</string>

    </property>

   </widget>

   <widget class="QPushButton" name="first">

    <property name="geometry">

     <rect>

      <x>11</x>

      <y>152</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>1</string>

    </property>

   </widget>

   <widget class="QPushButton" name="mul">

    <property name="geometry">

     <rect>

      <x>266</x>

      <y>152</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>*</string>

    </property>

   </widget>

   <widget class="QPushButton" name="third">

    <property name="geometry">

     <rect>

      <x>181</x>

      <y>152</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>3</string>

    </property>

   </widget>

   <widget class="QPushButton" name="six">

    <property name="geometry">

     <rect>

      <x>181</x>

      <y>205</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>6</string>

    </property>

   </widget>

   <widget class="QPushButton" name="four">

    <property name="geometry">

     <rect>

      <x>11</x>

      <y>205</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>4</string>

    </property>

   </widget>

   <widget class="QPushButton" name="five">

    <property name="geometry">

     <rect>

      <x>96</x>

      <y>205</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>5</string>

    </property>

   </widget>

   <widget class="QPushButton" name="sub">

    <property name="geometry">

     <rect>

      <x>266</x>

      <y>205</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>-</string>

    </property>

   </widget>

   <widget class="QPushButton" name="seven">

    <property name="geometry">

     <rect>

      <x>11</x>

      <y>258</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>7</string>

    </property>

   </widget>

   <widget class="QPushButton" name="add">

    <property name="geometry">

     <rect>

      <x>266</x>

      <y>258</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>+</string>

    </property>

   </widget>

   <widget class="QPushButton" name="eight">

    <property name="geometry">

     <rect>

      <x>96</x>

      <y>258</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>8</string>

    </property>

   </widget>

   <widget class="QPushButton" name="nine">

    <property name="geometry">

     <rect>

      <x>181</x>

      <y>258</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>9</string>

    </property>

   </widget>

   <widget class="QPushButton" name="cos">

    <property name="geometry">

     <rect>

      <x>96</x>

      <y>311</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>cos</string>

    </property>

   </widget>

   <widget class="QPushButton" name="sin">

    <property name="geometry">

     <rect>

      <x>11</x>

      <y>311</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>sin</string>

    </property>

   </widget>

   <widget class="QPushButton" name="tan">

    <property name="geometry">

     <rect>

      <x>181</x>

      <y>311</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>tan</string>

    </property>

   </widget>

   <widget class="QPushButton" name="Cal">

    <property name="geometry">

     <rect>

      <x>266</x>

      <y>311</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>=</string>

    </property>

   </widget>

   <widget class="QPushButton" name="point">

    <property name="geometry">

     <rect>

      <x>181</x>

      <y>364</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>.</string>

    </property>

   </widget>

   <widget class="QPushButton" name="ln">

    <property name="geometry">

     <rect>

      <x>11</x>

      <y>364</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>ln</string>

    </property>

   </widget>

   <widget class="QPushButton" name="log">

    <property name="geometry">

     <rect>

      <x>96</x>

      <y>364</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>log</string>

    </property>

   </widget>

   <widget class="QPushButton" name="zero">

    <property name="geometry">

     <rect>

      <x>266</x>

      <y>364</y>

      <width>75</width>

      <height>23</height>

     </rect>

    </property>

    <property name="text">

     <string>0</string>

    </property>

   </widget>

  </widget>

  <widget class="QMenuBar" name="menuBar">

   <property name="geometry">

    <rect>

     <x>0</x>

     <y>0</y>

     <width>352</width>

     <height>23</height>

    </rect>

   </property>

  </widget>

  <widget class="QToolBar" name="mainToolBar">

   <attribute name="toolBarArea">

    <enum>TopToolBarArea</enum>

   </attribute>

   <attribute name="toolBarBreak">

    <bool>false</bool>

   </attribute>

  </widget>

  <widget class="QStatusBar" name="statusBar"/>

 </widget>

 <layoutdefault spacing="6" margin="11"/>

 <resources/>

 <connections/>

</ui>
 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Qt实现的计算器 的相关文章

  • 深度学习推荐系统——Embedding

    深度学习推荐系统 Embedding Embedding概述Word2vecItem2vec Embedding概述 Embedding操作的主要作用是将稀疏向量转换成稠密向量 xff0c 向量之间的距离反映了对象之间的相似性 从另一空间表
  • 堆与栈区别,以及分配内存的快慢

    毫无疑问 xff0c 显然从栈上分配内存更快 xff0c 因为从栈上分配内存仅仅就是栈指针的移动而已 操作系统会在底层对栈提供支持 xff0c 会分配专门的寄存器存放栈的地址 xff0c 栈的入栈出栈操作也十分简单 xff0c 并且有专门的
  • ubuntu下realsence相机通过ros话题直接读取内参

    roslaunch realsense2 camera rs camera span class token punctuation span launch span class token comment 打开相机节点 span rost
  • 语义栅格地图(六) realsense实际测试

    1 在ros中启动realsense 测试输出话题 xff1a roslaunch realsense2 camera rs camera launch 测试输出点云 xff1a roslaunch realsense2 camera rs
  • VINS on RealSense D435i

    关于Realsense D435i运行VINS系列 前言 在SLAM中 xff0c 主要是以激光SLAM和视觉SLAM为主 xff0c 激光雷达直接可以获取三维点云坐标信息 xff0c 所以激光SLAM会比视觉SLAM稳定许多 xff0c
  • CAN 扩展帧和标准帧的适用范围

    刚接触CAN不久 xff0c 对很多CAN相关的知识不了解 xff0c 就难以进行灵活的运用 今天弄懂了CAN的标准帧和扩展帧的使用场合 xff0c 故此做一下笔记 首先 xff0c 得知道为什么会有这两种不同的帧 其实原因和IPV4和IP
  • ZCU104开发板:开发板组件描述

    1 Zynq UltraScale 43 XCUZU7EV MPSoC ZCU104板上安装了Zynq UltraScale 43 XCZU7EV 2FFVC1156 MPSoC xff0c 它在同一设备中集成了功能强大的处理系统 xff0
  • (超简单)Ubuntu/linux上搭建pytorch-gpu环境

    xff08 超简单 xff09 Ubuntu linux上搭建pytorch gpu环境 1 下载miniconda conda 1 下载miniconda conda conda和miniconda可选择在清华镜像源中下载 xff0c 这
  • GAN训练中遇到的mode collapse(模式崩塌)

    1 梯度 loss爆炸 xff08 NaN xff0c Inf xff09 这两天一直在训练自己的GAN模型 xff0c 训练过程中鉴别器极其不稳定 xff0c 训练的几个epoch之后经常出现NAN xff0c 在加入WGAN中的梯度惩罚
  • 如何训练GAN?能够让GAN work的方法和技巧

    如何训练GAN xff1f 能够让GAN work的方法和技巧 尽管在生成对抗网络 xff08 GAN xff09 中的研究继续改善了这些模型的基本稳定性 xff0c 但我们使用了许多技巧来训练它们并使它们日复一日地稳定 xff08 翻译自
  • batch size,学习率(learning rate),and training time

    batch size 学习率 xff08 learning rate xff09 and training time 1 batch size和leaning rate的关系 现在深度学习中的绝大多数算法采用梯度下降法来进行训练 xff0c
  • torch.optim.lr_scheduler:pytorch必须掌握的的4种学习率衰减策略

    梯度下降算法需要我们指定一个学习率作为权重更新步幅的控制因子 xff0c 常用的学习率有0 01 0 001以及0 0001等 xff0c 学习率越大则权重更新 一般来说 xff0c 我们希望在训练初期学习率大一些 xff0c 使得网络收敛
  • 虚拟内存与物理内存,自己理解,删除了一些细节,更容易懂

    其实虚拟内存就是字面意思 xff0c 虚拟保存在磁盘中的 xff0c 我们知道32为操作系统下一个进程是4g大小空间 xff0c 我们物理内存 xff08 也就是我们说的内存条 xff09 xff0c 假如我们以8g内存条定义 假如我们没有
  • 轻量型神经网络 shufflenet V1和shufflenet V2

    1 shufflenet V1 ShuffleNet是旷视科技 Face 43 43 提出的一种计算高效的CNN模型 xff0c 其和MobileNet和SqueezeNet等一样主要是想应用在移动端 所以 xff0c ShuffleNet
  • 详解C++中的const关键字

    1 const修饰指针 const修饰指针有三种情况 const修饰指针 常量指针 const修饰常量 指针常量 const即修饰指针 xff0c 又修饰常量 int main int a 61 10 int b 61 10 const修饰
  • CMake教程及使用案例

    1 CMake教程及使用案例 2 CMake Tutorial 3 https www cnblogs com crazyang p 14371953 html
  • gcc/g++编译选项&动态/静态库

    1 gcc g 43 43 编译选项 amp 动态 静态库
  • 外围设备对飞控的作用

    以下是我对外围设备的理解 xff08 如果理解有误 xff0c 请大佬们指正 xff09 桨叶 xff08 必须 xff09 xff1a 动力装置 电机 必须 xff1a 为无人机提供动力输出 电调ESC 必须 xff1a 电子调速器 控制
  • 飞控外围设备选型的注意事项

    合适的选型 xff08 如电机 43 桨叶 43 电池 xff09 可以兼顾无人机的航时和稳定性 xff0c 可将航时和稳定性发挥到极致 桨叶 xff1a 螺距和长度 桨叶的选择会影响无人机的航时和稳定性 xff0c 选的好航时和稳定性可以
  • STM32CubeMX学习笔记——FreeRTOS_任务创建与删除

    STM32CubeMX学习笔记 FreeRTOS 任务创建与删除 Github简介任务创建可视化创建方式代码创建方式 任务删除 Github https github com HaHaHaHaHaGe Planof2019 half tre

随机推荐

  • 关于串口发送的几个标志位

    首先了解STM32串口发送数据的简单过程 xff0c 如下图所示 发送 xff1a 软件将数据写到USARTx gt DR里面 xff0c 硬件自动把USARTx gt DR里面的数据并行转移到 发送移位寄存器 xff0c 然后硬件自动将发
  • TCP三步握手,以及相关问题

    三次握手是 TCP 连接的建立过程 在握手之前 xff0c 主动打开连接的客户端结束 CLOSE 阶段 xff0c 被动打开的服务器也结束 CLOSE 阶段 xff0c 并进入 LISTEN 阶段 随后进入三次握手阶段 xff1a 首先客户
  • HTTP digest认证

    HTTP的basic认证是通过明文来传输用户名和密码 xff0c 安全性不够 xff0c 因此HTTP又推出了摘要认证的方式来验证用户名和密码 流程和Basic认证差不多 1 浏览器访问服务端受保护的资源 xff0c 服务端返回401 同时
  • SLAM【十】回环检测

    SLAM 十 回环检测 回环检测的作用及意义作用意义 回环检测方法准确率和召回率词袋模型 字典字典的结构字典的创建相似度计算相似度评分的处理关键帧的处理检测之后的验证 参考 回环检测的作用及意义 作用 问题 xff1a 为了解决整个SLAM
  • ubuntu下切换默认python版本

    ubuntu下切换默认python版本 以 root 身份登录 xff0c 首先罗列出所有可用的python 替代版本信息如果出现以上所示的错误信息 xff0c 则表示 Python 的替代版本尚未被update alternatives
  • AVL分析飞机气动特性

    AVL xff0c 全称为Athena Vortex Lattice xff0c 是MIT的Mark Drela教授开发的一个气动分析程序 程序最初由Harold Youngren 1988年为MIT Athena TODOR航空软件集编写
  • ros_arduino_bridge+arduino+l298n控制编码电机(Arduino uno)

    踩了许多坑 xff0c 看了许多教程 xff0c 终于成功用ros arduino桥的方法实现了对电机的控制 xff0c 希望大家能通过我的教训少走一些弯路 注 xff1a 本教程的所有代码可以进入我主页下载 step1 ubuntu下安装
  • 典型TI LaunchPad 比较

    型号主芯片主频资源尺寸支持软件参考价格MSP EXP432P401R MSP432P401R 48MHz 256KB Flash 64KB RAM 32KB ROM 9 5cm 5 85cm Keil Energia CCS 199 EK
  • 关于反序列异常问题

    异常显示序列号不一致 xff0c 序列化和反序列化受serialVersionUID序列号控制 xff0c 异常原因 xff1a 对象序列化时忘了写显式序列号 xff0c 然后再反序列化才重写的序列号 xff0c 也就是 序列化和反序列化的
  • ros消息和服务error:The manifest (with format version 2) must not contain the following tags: run_depend

    在按ROS入门教程 xff08 点击打开链接 xff09 行进过程中到了执行 rosmsg show beginner tutorials Num 命令时 xff0c 出现提示 The manifest with format versio
  • 【Vue + ElementUI】el-progress 各类常用场景(自动计算percentage,format自定义显示文字)

    效果图 xff1a 1 当前数据结构 progressList planNum 150 计划数量 completeNum 80 完成数量 planNum 70 completeNum 70 planNum 70 completeNum 90
  • 音乐播放器的一些思路

  • Arduino笔记实验(初级阶段)—Keypad小键盘

    Arduino笔记实验 初级阶段 Keypad小键盘 文章目录 Arduino笔记实验 初级阶段 Keypad小键盘前言一 电路图二 集成库方案 Keypad 三方集成库代码实验效果展示 三 基于Arduino原生方案4 4按键膜结构图代码
  • Arduino笔记实验(初级阶段)—火焰传感器+有源蜂鸣器实验

    Arduino笔记实验 初级阶段 火焰传感器 43 有源蜂鸣器实验 文章目录 Arduino笔记实验 初级阶段 火焰传感器 43 有源蜂鸣器实验前言一 电路图二 火焰传感器 4引脚 有源蜂鸣器代码实验效果展示 三 火焰传感器火焰传感器模块示
  • Arduino笔记实验(初级阶段)—DHT11温湿度传感器

    Arduino笔记实验 初级阶段 DHT11温湿度传感器 文章目录 Arduino笔记实验 初级阶段 DHT11温湿度传感器前言一 电路图二 DHT11温湿度传感器实验代码实验效果展示 三 DHT11温湿度传感器实验总结 前言 自学笔记 x
  • C语言笔记-26-网络-UDP网络编程

    C语言笔记 26 网络 UDP网络编程 文章目录 C语言笔记 26 网络 UDP网络编程前言一 UDP编程模型概括三 UDP编程模型代码UDP服务端UDP客户端 总结 前言 自学笔记 xff0c 没有历史知识铺垫 xff08 省略百度部分
  • C++笔记-6-c++静态与单例

    C 43 43 笔记 6 c 43 43 静态与单例 文章目录 C 43 43 笔记 6 c 43 43 静态与单例前言一 静态静态成员变量静态成员函数 二 单例饿汉式懒汉式 总结 前言 自学笔记 xff0c 没有历史知识铺垫 xff08
  • C++笔记-4-c++类与继承

    C 43 43 笔记 4 c 43 43 类与继承 文章目录 C 43 43 笔记 4 c 43 43 类与继承前言一 类 Class 构造 析构函数拷贝构造和拷贝赋值 二 继承总结 前言 自学笔记 xff0c 没有历史知识铺垫 xff08
  • C++笔记-5-c++成员变量、函数指针

    C 43 43 笔记 5 c 43 43 成员变量 函数指针 文章目录 C 43 43 笔记 5 c 43 43 成员变量 函数指针前言一 成员变量指针二 成员函数指针总结 前言 自学笔记 xff0c 没有历史知识铺垫 xff08 省略百度
  • Qt实现的计算器

    写在前边 xff1a 这篇文章只是来带着大家一起实现一个基于Qt的计算器 中间会出现很多概念 xff0c 我们不做拓展介绍 xff0c 大家只要知道怎么用就好 xff0c 如果有需要我们后续再详细的对每个模块解析 1 首先介绍一下Qt xf