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

相关推荐
TechNomad2 小时前
Qt开发:QtConcurrent介绍和使用
qt
十秒耿直拆包选手12 小时前
Qt:主窗体(QMainwindow)初始化注意事项
c++·qt
-凌凌漆-18 小时前
【Qt】Qt QML json处理
开发语言·qt·json
海天鹰1 天前
Qt:图片切割
qt
做一个坚强的女汉子1 天前
QT保存日志到文件中以及捕捉崩溃日志
开发语言·qt
顾苏洋19901 天前
qt绘制饼状图并实现点击即放大点击部分
开发语言·qt
笑鸿的学习笔记1 天前
qt-C++笔记之布局管理`space` 和 `margin`的区别
c++·笔记·qt
轩情吖1 天前
Qt常用控件之QWidget(一)
c++·qt·geometry·qwidget·qpushbutton·客户端开发·enabled
没学上了1 天前
Qt去噪面板搭建
开发语言·qt
peihexian1 天前
vcpkg交叉编译qt等过程记录(未完成)
开发语言·qt