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

相关推荐
赵民勇1 小时前
Qt QML Component.onCompleted 和 Component.onDestruction 详解
qt
我不是8神1 小时前
Qt 知识点全面总结
开发语言·qt
Lhan.zzZ5 小时前
基于Qt的UDP广播发现与TCP连接系统的设计与实现
qt·tcp/ip·udp
leiming66 小时前
c++ QT 开发第二天,用ui按钮点亮实体led
开发语言·qt·ui
hqwest6 小时前
码上通QT实战04--主窗体布局
开发语言·css·qt·布局·widget·layout·label
leiming67 小时前
c++ qt开发第一天 hello world
开发语言·c++·qt
赵民勇8 小时前
QML Base Type 详解
qt
hqwest8 小时前
码上通QT实战07--主窗体消息栏设计
开发语言·qt·qt事件·主窗体·stackedwidget
hqwest8 小时前
码上通QT实战06--导航按钮事件
开发语言·qt·mousepressevent·qfont·qpainter·qlineargradient·setbrush
CC.GG9 小时前
【Qt】常用控件----容器类控件(QGroupBox、QTabWidget )以及布局管理器
开发语言·qt