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教程

相关推荐
我不是疯子是傻子4 小时前
Qt 实时曲线卡顿优化:从QPainter到OpenGL的3级加速实战
开发语言·qt
我不是疯子是傻子6 小时前
串口通信数据帧粘包拆包再进化:基于 Qt 的滑动窗口与 CRC 校验实战
开发语言·qt
程序员老陆6 小时前
Qt中实现窗口真全屏(覆盖Windows任务栏)
开发语言·windows·qt
艾莉丝努力练剑10 小时前
【QT:解决问题】Qt5Core.dll:无法定位程序输入点
java·开发语言·qt·学习·面试
秋田君1 天前
QT_JSON文件操作
开发语言·qt·json
大白同学4211 天前
初识Qt——信号和槽
开发语言·qt
秋田君1 天前
QT_INI文件操作
开发语言·qt
≮傷£≯√1 天前
FFmpeg + qt 音频播放
qt·ffmpeg·音视频
youqingyike1 天前
【无标题】
前端·qt
程序员老陆1 天前
Qt::WidgetAttribute 常用属性详解
开发语言·qt