qt写代码判断一个数字是否可以被7整除

普通小程序c+gtk可以跨平台,c++跨平台用qt比较方便,deepinlinuxv20.9应用商店安装dtk-ide,就可以开发qt了,用上dtk模板就是dtk应用,qt模板就是qt跨平台应用

复制代码
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QRegExpValidator>
#include <QDebug>
#include <QDesktopWidget>

static void FormToCenter(QWidget *frm)
{
    frm->move(qApp->desktop()->availableGeometry(frm).center()-frm->rect().center());
}

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QRegExp regExp("[0-9]*");
    QValidator *validator = new QRegExpValidator(regExp, ui->lineEdit->window());
    ui->lineEdit->setValidator(validator);
    FormToCenter(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_evaluateButton_clicked()
{
    int x=ui->lineEdit->text().toInt();
    if(x>1000){
        qDebug()<<"y "<<x/1000;
        qDebug()<<"y 2 "<<x%1000;
        x=x/1000-x%1000;
        qDebug()<<"x "<<x;
    }
    if(0==(x%7)){
        ui->label->setText("整除");
    }else{
         ui->label->setText("不可被7整除");
    }
}

void MainWindow::on_exitButton_clicked()
{
    this->close();
}

qtcreator内嵌qtdesigner,可以画界面,画出来界面也可给python等语言调用,在qt里封装更严实,qt做出来应用需要带一堆qt库,win下可以windeployqt xx.exe能找到需要的依赖库,mac下是macdeployqt,mac下还能封装成dmg包,linux下用的第三方linuxdeployqt

下载

https://github.com/probonopd/linuxdeployqt/releases

使用

https://blog.51cto.com/xiaohaiwa/5383414

使用说明详细,并且后打包成deb教程

相关推荐
ae_zr3 小时前
QT动态编译应用后,如何快速获取依赖
开发语言·qt
LYOBOYI1234 小时前
qml的对象树机制
c++·qt
菜鸟小芯4 小时前
Qt Creator 集成开发环境下载安装
开发语言·qt
牵牛老人8 小时前
Qt中集成 MQTT 来实现物联网通信:从原理到实战全解析
开发语言·qt·物联网
LYOBOYI1238 小时前
qml的布局策略
c++·qt
小小码农Come on10 小时前
QT常用控件:QListWidget
开发语言·qt
侯孟禹10 小时前
Gemini写的抠图工具
qt·opencv
空空空空空空空空空空空空如也11 小时前
QT通过编译宏区分x86 linux arm的方法
linux·开发语言·qt
四维碎片21 小时前
【Qt】UDP跨平台调试工具
qt·学习·udp
踏过山河,踏过海1 天前
【用ui文件做个简单工具的开发,为什么修改完ui后,程序重新编译运行后,GUI界面还是不变呢?】
qt·ui