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

相关推荐
Fruit_Caller12 小时前
GmSSL 编译与 Qt 项目集成问题排查记录(-lssl-1_1-x64 -lcrypto-1_1-x64)
开发语言·qt
小茗的嵌入式学习日记12 小时前
基于IMX6ULL的车载中控系统
linux·c语言·qt
娇娇yyyyyy13 小时前
QT编程(7): Qt主窗口和菜单栏
数据库·qt·microsoft
A.A呐14 小时前
【QT第四章】QT窗口
服务器·数据库·qt
亚马逊云开发者14 小时前
MCP 协议实战:用 Amazon Bedrock 让 AI Agent 安全调用云服务的完整方案
开发语言·qt·安全
IOT-Power14 小时前
Qt/C++ 项目 pro` 文件管理办法
qt
蓝天智能1 天前
QT实战:Qt6 字符编码避坑指南
开发语言·qt
森G1 天前
14、QT项目构成
qt
Larry_Yanan1 天前
QML学习笔记(六十四)动画相关:State状态、Transition过渡和Gradient渐变
开发语言·c++·笔记·qt·学习
Ronin3051 天前
【Qt常用控件】显示类控件
开发语言·qt·常用控件·显示类控件