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

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

前言

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


运行结果


文章目录

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

一、所需工具软件

1. VS2019, Qt
2. C++

二、使用步骤

代码如下(示例):
cpp 复制代码
#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

相关推荐
vortex57 分钟前
探索 Shell:选择适合你的命令行利器 bash, zsh, fish, dash, sh...
linux·开发语言·bash·shell·dash
zzc9219 分钟前
MATLAB仿真生成无线通信网络拓扑推理数据集
开发语言·网络·数据库·人工智能·python·深度学习·matlab
HUN金克斯18 分钟前
C++/C函数
c语言·开发语言·c++
慢半拍iii19 分钟前
数据结构——F/图
c语言·开发语言·数据结构·c++
钢铁男儿21 分钟前
C# 表达式和运算符(表达式和字面量)
开发语言·c#
编程有点难24 分钟前
Python训练打卡Day43
开发语言·python·深度学习
m0_6371469330 分钟前
零基础入门 C 语言基础知识(含面试题):结构体、联合体、枚举、链表、环形队列、指针全解析!
c语言·开发语言·链表
LjQ204038 分钟前
网络爬虫一课一得
开发语言·数据库·python·网络爬虫
你是狒狒吗1 小时前
TM中,return new TransactionManagerImpl(raf, fc);为什么返回是new了一个新的实例
java·开发语言·数据库