当前位置: 首页 > news >正文

企业建设网站公司百度网址大全下载安装

企业建设网站公司,百度网址大全下载安装,自适应网站模板怎么做,新企业建网站前言: 以前 windows下做工具主要是MFC,趁有点空时间,研究了QT,感觉跟MFC 差不多,VS 比 QT CREATOR 还是强大,不过QT可以跨平台,功能更强大,MFC 只能在win平台下.; 1:环境…

前言:
以前 windows下做工具主要是MFC,趁有点空时间,研究了QT,感觉跟MFC 差不多,VS 比 QT CREATOR 还是强大,不过QT可以跨平台,功能更强大,MFC 只能在win平台下.;
1:环境
win10
Qt 6.8 LTS
Qt Creator 14.0.2
MINGW :13.1
download:https://download.qt.io/official_releases/online_installers/
选择 qt-unified-windows-x64-online.exe
2:安装
已经安装好了,真是吃硬盘, 最少准备40G,用QT一定要用ssd,最差是sata3,最好是m2 pcie3及以上,512G起吧,IOPS 差用起来难受,
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
3:常用控件
左边MFC(VS2022) 右边 为 qt的
在这里插入图片描述
常用控件都差不多,会MFC,只要稍微熟悉了基本用法就OK了,常用控件都这样;

4:qt跟MFC 对比,注意事项
1> 创建工程
在这里插入图片描述
qt 选择cmake(qmake,cmake,qbs) ,cmake 相对比较熟悉(linux下编译用到)
MFC 选择MFC应用
在这里插入图片描述

下面简单的做个DMO ,
几个button tableview menu dialog 等
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

直接上代码
mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QMainWindow>
#include <QButtonGroup>
#include <qitemselectionmodel.h>
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACEclass MainWindow : public QMainWindow
{Q_OBJECTpublic:MainWindow(QWidget *parent = nullptr);~MainWindow();private:Ui::MainWindow *ui;QButtonGroup * m_group1;public slots:void ClickButton_previous(bool b);void ClickButton_previous2();void onBtnFunc(int n);void btnToggled(int,bool);void slotselectionChanged(const QItemSelection &selected, const QItemSelection &deselected);void receiveData(QString data);
};
#endif // MAINWINDOW_H

mainwindow.cpp

#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include "dialog.h"#include <QStandardItemModel>
#include <QStringListModel>
#include "mylistmodel.h"
#include "qlogging.h"MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
{ui->setupUi(this);//查找名为label_2的QLabel对象,并返回QLabel * re2=  findChild<QLabel*>("label1");re2->setText("test111");//   QAction * p = new QAction();// connect(newAction, &QAction::triggered, this, &MainWindow::onNewFile);//connect(action, SIGNAL(triggered()), this, SLOT(onFileNew()));// QAction
// public Q_SLOTS:
//     void trigger() { activate(Trigger); }
//     void hover() { activate(Hover); }
//     void setChecked(bool);
//     void toggle();
//     void setEnabled(bool);
//     void resetEnabled();
//     inline void setDisabled(bool b) { setEnabled(!b); }
//     void setVisible(bool);// Q_SIGNALS:
//     void changed();
//     void enabledChanged(bool enabled);
//     void checkableChanged(bool checkable);
//     void visibleChanged();
//     void triggered(bool checked = false);
//     void hovered();
//     void toggled(bool);//SIGNAL SLOT 带参数要统一,不然找不到///ok1// QMetaObject::Connection c1 = connect(ui->action111_111, SIGNAL(triggered(bool)), this, SLOT(ClickButton_previous(bool)));// if(c1 != NULL){//     qDebug("3333");// }//  QAction *newAction = new QAction(tr("&New"), this);//connect(newAction, &QAction::triggered, this, &MainWindow::onNewFile);///ok2QMetaObject::Connection c1 = connect(ui->action111_111, &QAction::triggered, this, &MainWindow::ClickButton_previous);if (c1 != NULL){}//button
// public Q_SLOTS:
//     void setIconSize(const QSize &size);
//     void animateClick();
//     void click();
//     void toggle();
//     void setChecked(bool);// Q_SIGNALS:
//     void pressed();
//     void released();
//     void clicked(bool checked = false);
//     void toggled(bool checked);QMetaObject::Connection c2 = connect(ui->pushButton1, SIGNAL(clicked()), this, SLOT(ClickButton_previous2()));if(c2 != NULL){qDebug("3333");}connect(ui->pushButton2,&QPushButton::clicked,[=](){re2->setText("pushButton2");});//qradiobutton// 连接信号与槽函数m_group1 = new QButtonGroup(this);m_group1->addButton (ui->radioButton, 0);m_group1->addButton (ui->radioButton_2, 1);m_group1->setExclusive(true);//connect (m_group1, SIGNAL (buttonClicked(int)), this, SLOT(onBtnFunc(int)));connect (m_group1, SIGNAL(idToggled(int,bool)), this, SLOT(btnToggled(int,bool)));// connect(ui->radioButton, SIGNAL(idToggled(int,bool)), this, SLOT(btnToggled(int,bool)));// connect(ui->groupBox1, &QRadioButton::toggled, this, SLOT(btnToggled(int,bool)));QStandardItemModel *model= new QStandardItemModel();// 添加列头model->setHorizontalHeaderLabels(QStringList() << "Column 1" << "Column 2" << "Column 3");// 添加数据for (int row = 0; row < 10; ++row) {for (int col = 0; col < 3; ++col) {QStandardItem *item = new QStandardItem(QString("Row %1, Column %2").arg(row).arg(col));model->setItem(row, col, item);}}QTableView *tableView= ui->tableView1;tableView->setModel(model);tableView->setSelectionBehavior(QAbstractItemView::SelectRows);// 显示窗口//  tableView->show();//选择行事件//ok_1// QObject::connect(tableView->selectionModel(), &QItemSelectionModel::selectionChanged,//                  [&](const QItemSelection &selected, const QItemSelection &deselected){//                      QModelIndexList indexes = selected.indexes();//                      if (!indexes.isEmpty()) {//                          QModelIndex firstIndex = indexes.first();//                          qDebug() << "Row" << firstIndex.row() << "selected.";//                      }//                  });// public Q_SLOTS://     virtual void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command);//     virtual void select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command);//     virtual void select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command);//     virtual void clear();//     virtual void reset();//     void clearSelection();//     virtual void clearCurrentIndex();// Q_SIGNALS://     void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);//     void currentChanged(const QModelIndex &current, const QModelIndex &previous);//     void currentRowChanged(const QModelIndex &current, const QModelIndex &previous);//     void currentColumnChanged(const QModelIndex &current, const QModelIndex &previous);//     void modelChanged(QAbstractItemModel *model);//ok_2///connect(tableView->selectionModel(),&QItemSelectionModel::selectionChanged,this,&MainWindow::slotselectionChanged);
}MainWindow::~MainWindow()
{delete ui;
}void MainWindow::ClickButton_previous(bool b){QLabel * re2=  findChild<QLabel*>("label1");re2->setText("test2221");//click menuqDebug()<<"dialog top";Dialog dialog(this);//子窗口给父窗口发送消息//connect(sender, &SenderClass::signalName, receiver, &ReceiverClass::slotName);connect(&dialog, &Dialog::sendData,this,&MainWindow::receiveData);//连接信号与槽dialog.show(); //or connect(&child, &child::sendData,this,&MainWindow::receiveData);//连接信号与槽dialog.exec();  //以模态方式打开对话框(打开主窗口时不能使用主窗口)
}void MainWindow::ClickButton_previous2(){QLabel * re2=  findChild<QLabel*>("label1");re2->setText("test3333");
}void MainWindow::onBtnFunc(int n)
{quint16 a = m_group1->checkedId();QLabel * re2=  findChild<QLabel*>("label1");QString  q= "onBtnFunc"+QString::number(n);re2->setText(q);}void MainWindow::btnToggled(int n ,bool b){qDebug()<<n<<b;QLabel * re2=  findChild<QLabel*>("label1");QString  q= QString::number(n)+"onBtnFunc";re2->setText(q);
}
//
void MainWindow::slotselectionChanged(const QItemSelection &selected, const QItemSelection &deselected){QModelIndexList indexes = selected.indexes();if (!indexes.isEmpty()) {QModelIndex firstIndex = indexes.first();qDebug() << "Row" << firstIndex.row() << "selected.";}
}void MainWindow::receiveData(QString data)//接收子窗口发送的数据
{qDebug()<<"recv dialog msg"<<data ;
}

dialog.h

#ifndef DIALOG_H
#define DIALOG_H#include <QDialog>namespace Ui {
class Dialog;
}class Dialog : public QDialog
{Q_OBJECTpublic:explicit Dialog(QWidget *parent = nullptr);~Dialog();private slots:void on_pushButton_clicked();
public :signals:void sendData(QString data); //点击发送时发送的QString型data信号 给 主窗口 private:Ui::Dialog *ui;
};#endif // DIALOG_H

dialog.cpp

#include "dialog.h"
#include "ui_dialog.h"
#include <QObject>
// #define SIGNAL(arg) #arg
// #define SLOT(arg) #argDialog::Dialog(QWidget *parent): QDialog(parent), ui(new Ui::Dialog)
{ui->setupUi(this);connect(ui->pushButton, &QPushButton::clicked, this, &Dialog::on_pushButton_clicked);
}Dialog::~Dialog()
{delete ui;
}void Dialog::on_pushButton_clicked()
{qDebug()<<"Dialog";emit sendData("Dialog"); //
}

connect(button, SIGNAL(clicked()), this, SLOT(handleButtonClicked()));
connect(sender, &SenderClass::signalName, receiver, &ReceiverClass::slotName);
有重载函数时可以用 qOverload 指明
void do_click(bool b)
connect(sender, &SenderClass::signalName, this, qOverload(&Widget::do_click)); //函数里带参数bool b
void do_click()
connect(sender, &SenderClass::signalName, this, qOverload<>(&Widget::do_click));//函数里不带参数
一个信号可以连接多个slot
类试于 Observer Pattern(观察者模式)
connect(sender, &SenderClass::signalName, receiver1, &ReceiverClass1::slotName);
connect(sender, &SenderClass::signalName, receiver2, &ReceiverClass2::slotName);

5:测试结果
在这里插入图片描述
6:如果觉得有用,麻烦点个赞,加个收藏
下章讲述 qml,感觉跟lua 类试,都可以相互调用

http://www.mmbaike.com/news/99360.html

相关文章:

  • ugg网站vps主机百度竞价点击神器下载安装
  • 网站建设网络工作室 开办需要那些手续2022最新国内新闻50条简短
  • 建筑网校有哪些西安seo代运营
  • 做网站去哪里好完整html网页代码案例
  • 网站建设的公司这个宝鸡seo排名
  • 佛山网站建设怎么做百度下载安装最新版
  • 主页导航网站建设定制志鸿优化设计答案网
  • 有什么可以做兼职的正规网站2022年度关键词
  • 旅游门户网站有哪些竞价托管推广哪家好
  • 个人网站建设的论文企业如何做好网络营销
  • 云上铺会员管理系统官网网站优化公司收费
  • 手机网站推广怎么做快速排名优化怎么样
  • 教育网站开发文档模板搜索优化推广公司
  • 永久免费网站建商城大数据查询
  • 中国风优秀个人网站欣赏广州seo
  • 做设计在哪个网站接单如何做好互联网营销
  • 寿光做网站的公司友链网
  • 东莞网站建设报价 一呼百应app推广平台放单平台
  • 电商购物网站开发需求分析湖南正规seo优化报价
  • 网站备案照片 多少钱网页设计与网站开发
  • 网站建设及维护费seo网站推广批发
  • 大兴做网站建设制作今日十大热点新闻头条
  • 电商网站建设方案模板郑州网站公司哪家好
  • 公司网站制作公想要推广页
  • 网站推广软件费用是多少网络营销就业方向和前景
  • 怎么样做企业网站游戏推广员拉人技巧
  • 产品开发软件江苏seo和网络推广
  • 长春企业网站排名优化怎样在网上做宣传
  • 福田附近做网站公司常州谷歌推广
  • 做网站打广告犯法吗seo资讯网