qmessagebox

Qt 操作QDomDocument对象修改节点

假如想象 提交于 2019-12-03 09:50:46
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 本文链接: https://blog.csdn.net/liulihuo_gyh/article/details/41321369 代码部分: QFile file(filePath); if (!file.open(QFile::ReadOnly | QFile::Text)) { QMessageBox::critical(NULL,tr("错误"),tr("无法打开%1文件").arg(filePath),QMessageBox::Ok); return; } QString error; int row = 0; int col= 0 ; QDomDocument dom; if (!dom.setContent(&file, false, &error, &row, &col)) { QMessageBox::warning(0, tr("error"), tr("错误%1, 行%2, 列%3").arg(error).arg(row).arg(col), QMessageBox::Yes); file.close(); return; } QDomElement root = dom.documentElement();// 根节点 QDomNodeList

QT系统授权及获取MAC、IP地址

匿名 (未验证) 提交于 2019-12-03 00:26:01
界面 mainwindow.cc #include "mainwindow.hpp" #include "ui_mainwindow.h" #include "autherr.h" #include "licenseimport.h" #include <QNetworkInterface> #include <QListWidget> #include <iostream> #include <QMessageBox> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->pushButton,SIGNAL(clicked(bool)),this,SLOT(onSendButtonClicked())); } QString MainWindow::getHostMacAddress() { QList<QNetworkInterface> nets = QNetworkInterface::allInterfaces(); foreach (QNetworkInterface net, nets) { QListWidgetItem *item=new QListWidgetItem(net

qt常用消息对话框

匿名 (未验证) 提交于 2019-12-02 23:48:02
一、消息对话框类型 二、用法 函数原型: StandardButton QMessageBox::information(QWidget * parent, const QString & title,                         const QString & text, StandardButtons buttons = Ok,                         StandardButton defaultButton = NoButton) [static] 第一个参数是父控件指针 第二个参数是标题 第三个参数是内容 第四个参数是窗口里面要多少个按钮(默认为OK) 第五个参数指定按下Enter时使用的按钮。(默认为NoButton,此时QMessageBox会自动选择合适的默认值。) 返回值:StandardButton 一般程序按照返回具体的按钮值执行相应的动作,比如返回 QMessageBox::Save,就知道按下了保存按钮,下一步执行保存动作 QMessageBox::Ok QMessageBox::Open QMessageBox::Save QMessageBox::Cancel QMessageBox::Close QMessageBox::Discard QMessageBox::Apply QMessageBox:

Qt自定义MessageBox

匿名 (未验证) 提交于 2019-12-02 23:36:01
Qt自定义MessageBox QMessageBox *msgBox = new QMessageBox(); msgBox->setIcon(QMessageBox::Warning); msgBox->setWindowTitle(codec->toUnicode(“警告”)); msgBox->setText(codec->toUnicode(“确定是否删除!”)); QPushButton *btn1 = msgBox->addButton(codec->toUnicode(“确定”),QMessageBox::AcceptRole); btn1->setMinimumWidth(50); QPushButton *btn2 = msgBox->addButton(codec->toUnicode(“取消”),QMessageBox::RejectRole); btn2->setMinimumWidth(50); msgBox->setWindowFlags(Qt::WindowStaysOnTopHint); msgBox->exec(); if(btn1 == msgBox->clickedButton()) { do(); } 文章来源: https://blog.csdn.net/Leroy888/article/details/90667976

PyQt5--MessageBox

匿名 (未验证) 提交于 2019-12-02 22:11:45
1 # -*- coding:utf-8 -*- 2 ''' 3 Created on Sep 13, 2018 4 5 @author: SaShuangYiBing 6 ''' 7 import sys 8 from PyQt5.QtWidgets import QApplication,QWidget,QMessageBox,QPushButton 9 from PyQt5.QtCore import QCoreApplication 10 11 class New_test(QWidget): 12 def __init__(self): 13 super().__init__() 14 self.initUI() 15 16 def initUI(self): 17 qbtn = QPushButton('Quit',self) # 创建了一个按钮。按钮是一个QPushButton类的实例。 18 # 构造方法的第一个参数是显示在button上的标签文本。第二个参数是父组件。 19 # 父组件是Example组件,它继承了QWiget类。 20 qbtn.clicked.connect(QCoreApplication.instance().quit) 21 qbtn.resize(qbtn.sizeHint()) 22 qbtn.move(100,50) 23 self

Yes/No message box using QMessageBox

自作多情 提交于 2019-12-02 15:00:00
How do I show a message box with Yes/No buttons in Qt, and how do I check which of them was pressed? I.e. a message box that looks like this: You would use QMessageBox::question for that. Example in a hypothetical widget's slot: #include <QApplication> #include <QMessageBox> #include <QDebug> // ... void MyWidget::someSlot() { QMessageBox::StandardButton reply; reply = QMessageBox::question(this, "Test", "Quit?", QMessageBox::Yes|QMessageBox::No); if (reply == QMessageBox::Yes) { qDebug() << "Yes was clicked"; QApplication::quit(); } else { qDebug() << "Yes was *not* clicked"; } } Should work

PyQt5: QMessageBox vanishes after starting

眉间皱痕 提交于 2019-12-02 12:30:46
When I invoke Error Message One (see comments in code) the message quickly appears and then vanishes. But if I invoke Error Message Two, it appears and only vanishes when I click on the 'OK' button. How can I fix it so that Error Message One works like Error Message Two? try: connection = pymysql.connect(host = 'localhost', user = 'root', db = 'Telephon Register', cursorclass = pymysql.cursors.DictCursor) cur = connection.cursor() if number!= "": cur.execute("SELECT Number FROM formen WHERE Telephonebook = " + self.number.text() ) result = cur.fetchone() if len(result) == 0: cur.execute(

Qt简单项目实例之(二)——多功能计算器

倾然丶 夕夏残阳落幕 提交于 2019-12-02 06:47:21
有问题可以加我QQ:2273864757 进行交流学习!!!! 一.简单介绍 整个计算器设计整体按照“插件式,微内核”进行开发,里面包含各个功能的插件,将这些插件集成到我们的主工程之上。 首先,展示相关的功能截图: 此计算器包含基本的加减乘除运算之外,还包含有大整数计算工具,线代计算工具,多项式求解等计算工具,可以在工具下拉菜单里进行选择: 管理器可以记录我们输入的历史记录,常规菜单可以对整个界面的语言和背景颜色等等进行设置: 二.具体实现步骤 2.1 整体界面设置 整体界面设置通过读取配置文件进行整体界面的搭建,属性设置也通过保存到配置文件中进行存储,方便下次打开后使用上次保存的具体信息: void Calculator::readSettings() { QSettings settings; //The QSettings constructor takes arguments that identify your company and the name of the product. //This ensures that the settings for different applications are kept separately. //调整窗口的位置 QPoint pos = settings.value("pos", QPoint(350, 200))

结对编程作业

青春壹個敷衍的年華 提交于 2019-12-01 14:01:00
一、GitHub地址 https://github.com/huangzihaohzh/ExerciseMaker 二、估计耗费的时间 PSP2.1 Personal Software Process Stages 预估耗时(分钟) 实际耗时(分钟) Planning 计划 40 40 · Estimate · 估计这个任务需要多少时间 40 40 Development 开发 1400 1550 · Analysis · 需求分析 100 120 · Design Spec · 生成设计文档 60 70 · Design Review · 设计复审 40 50 · Coding Standard · 代码规范 30 40 · Design · 具体设计 90 100 · Coding · 具体编码 900 950 · Code Review · 代码复审 60 70 · Test · 测试(自我测试,修改代码,提交修改) 120 150 Reporting 报告 130 140 · Test Report · 测试报告 60 80 · Size Measurement · 计算工作量 30 20 · Postmortem & Process Improvement Plan · 事后总结, 并提出过程改进计划 40 40 合计   1530 1690 三、效能分析 优化时间