QT+C++桌面程序窗体框架模板-中英文切换-文件打开历史记录-工具选项设置

发布时间:2024年01月21日

程序示例精选
QT+C++桌面程序窗体框架模板-中英文切换-文件打开历史记录-工具选项设置
如需安装运行环境或远程调试,见文章底部个人QQ名片,由专业技术人员远程协助!

前言

这篇博客针对《QT+C++桌面程序窗体框架模板-中英文切换-文件打开历史记录-工具选项设置》编写代码,代码整洁,规则,易读。 学习与应用推荐首选。


运行结果


文章目录

一、所需工具软件
二、使用步骤
???????1. 主要代码
???????2. 运行结果
三、在线协助

一、所需工具软件

???????1. VS2019, Qt
???????2. C++

二、使用步骤

代码如下(示例):

#include "parametersetting.h"
#include "ui_parametersetting.h"

ParameterSetting::ParameterSetting(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ParameterSetting)
{
    ui->setupUi(this);

    //QObject::connect(ui->pushButtonSetting, SIGNAL(clicked()), this, SLOT(on_settingConfirm_clicked()));
    QObject::connect(ui->pushButtonSetting, SIGNAL(clicked()), this, SLOT(settingConfirm_clicked()));


    QObject::connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(subwin1Click()));
    QObject::connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(subwin2Click()));
    QObject::connect(ui->pushButton_3, SIGNAL(clicked()), this, SLOT(subwin3Click()));
    QObject::connect(ui->pushButton_4, SIGNAL(clicked()), this, SLOT(subwin4Click()));
    QObject::connect(ui->pushButton_5, SIGNAL(clicked()), this, SLOT(subwin5Click()));
    QObject::connect(ui->pushButton_7, SIGNAL(clicked()), this, SLOT(subwin6Click()));
    QObject::connect(ui->pushButton_8, SIGNAL(clicked()), this, SLOT(subwin7Click()));
    QObject::connect(ui->pushButton_9, SIGNAL(clicked()), this, SLOT(subwin8Click()));
    QObject::connect(ui->pushButton_6, SIGNAL(clicked()), this, SLOT(subwin9Click()));
    QObject::connect(ui->pushButton_10, SIGNAL(clicked()), this, SLOT(subwin10Click()));
    QObject::connect(ui->pushButton_12, SIGNAL(clicked()), this, SLOT(subwin11Click()));
    QObject::connect(ui->pushButton_11, SIGNAL(clicked()), this, SLOT(subwin12Click()));

   

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


void ParameterSetting::settingConfirm_clicked()
{
    QString X_RangeMax = ui->lineEdit->text();
    QString X_RangeMin = ui->lineEdit_4->text();
    QString Y_RangeMax = ui->lineEdit_2->text();
    QString Y_RangeMin = ui->lineEdit_5->text();

    qDebug()<<"X_RangeMax: "<<X_RangeMax;
    qDebug()<<"X_RangeMin: "<<X_RangeMin;
    qDebug()<<"Y_RangeMax: "<<Y_RangeMax;
    qDebug()<<"Y_RangeMin: "<<Y_RangeMin;

    std::ofstream cfgFile("config.cfg");
    if (!cfgFile) {
        std::cerr << "Cannot open the file for writing." << std::endl;
        return;
    }

    cfgFile << "setting1="<<X_RangeMax.toStdString() << std::endl;
    cfgFile << "setting2="<<X_RangeMin.toStdString() << std::endl;
    cfgFile << "setting3="<<Y_RangeMax.toStdString() << std::endl;
    cfgFile << "setting4="<<Y_RangeMin.toStdString() << std::endl;

    cfgFile.close();

    close(); 

}



#if 1
void ParameterSetting::onButtonClicked()
{

    //ui->pushButton->setStyleSheet("QPushButton { background-color:  #FFFFFF;  font-family: 'Microsoft YaHei'; font-size: 12px;border: none; width:50px;height:30px}");

    QPushButton* clickedButton = qobject_cast<QPushButton*>(sender());
    if (clickedButton) {
        if (lastClickedButton) {

            lastClickedButton->setStyleSheet("QPushButton { background-color: #E1E1E1;  font-family: 'Microsoft YaHei'; font-size: 12px; border: none;width:50px;height:30px}");

        }

        clickedButton->setStyleSheet("QPushButton { background-color: rgb(161,216,232); font-family: 'Microsoft YaHei'; font-size: 12px; border: none;width:50px;height:30px}");

        lastClickedButton = clickedButton;
    }
}


void ParameterSetting::subwin1Click()
{
    qDebug() << "bbb";
    ui->stackedWidget->update();
    ui->stackedWidget->setCurrentIndex(0);

}

void ParameterSetting::subwin2Click()
{
    qDebug() << "aaa";
    ui->stackedWidget->update();
    ui->stackedWidget->setCurrentIndex(1);
}

void ParameterSetting::subwin3Click()
{
    qDebug() << "aaa";
    ui->stackedWidget->update();
    ui->stackedWidget->setCurrentIndex(2);
}

void ParameterSetting::subwin4Click()
{
    qDebug() << "aaa";
    ui->stackedWidget->update();
    ui->stackedWidget->setCurrentIndex(3);
}


#endif





运行结果


在这里插入图片描述

三、在线协助:

如需安装运行环境或远程调试,见文章底部个人 QQ 名片,由专业技术人员远程协助!

1)远程安装运行环境,代码调试
2)Visual Studio, Qt, C++, Python编程语言入门指导
3)界面美化
4)软件制作
5)云服务器申请
6)网站制作

当前文章连接:https://blog.csdn.net/alicema1111/article/details/132666851
个人博客主页https://blog.csdn.net/alicema1111?type=blog
博主所有文章点这里:https://blog.csdn.net/alicema1111?type=blog

博主推荐:
Python人脸识别考勤打卡系统:
https://blog.csdn.net/alicema1111/article/details/133434445
Python果树水果识别https://blog.csdn.net/alicema1111/article/details/130862842
Python+Yolov8+Deepsort入口人流量统计:https://blog.csdn.net/alicema1111/article/details/130454430
Python+Qt人脸识别门禁管理系统:https://blog.csdn.net/alicema1111/article/details/130353433
Python+Qt指纹录入识别考勤系统:https://blog.csdn.net/alicema1111/article/details/129338432
Python Yolov5火焰烟雾识别源码分享:https://blog.csdn.net/alicema1111/article/details/128420453
Python+Yolov8路面桥梁墙体裂缝识别:https://blog.csdn.net/alicema1111/article/details/133434445

文章来源:https://blog.csdn.net/alicema1111/article/details/135730773
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。