首页
AI
爬虫
爬虫案例
JS逆向技巧
APP逆向
嵌入式开发
C语言入门视频教程
模电数电
51/52单片机
STM32
Linux嵌入式
文学修养
感动和励志文字
生活哲理
随手乱写
IT计算机
QT学习之路
数据库设计
网站搭建
微信开发
Java
计算机知识
NCRE全国计算机等级考试
编程语言
Web程序设计
关于我们
广告招租
表白网页制作
搜索
登录
搜索
RainFly
明确一个目标,这很重要!
累计撰写
216
篇文章
累计收到
4779
条评论
首页
栏目
首页
AI
爬虫
爬虫案例
JS逆向技巧
APP逆向
嵌入式开发
C语言入门视频教程
模电数电
51/52单片机
STM32
Linux嵌入式
文学修养
感动和励志文字
生活哲理
随手乱写
IT计算机
QT学习之路
数据库设计
网站搭建
微信开发
Java
计算机知识
NCRE全国计算机等级考试
编程语言
Web程序设计
关于我们
广告招租
表白网页制作
QT学习之路
2017-12-7
QT5.8.0实现ARM交叉编译
需求:编译安装QT 5.8.0 ARM +linux 版本 环境:Ubuntu 14.04 32bit 个人需要编译安装了 i386-linux-Qt5.8.0, 第一步: 下载文件 Qt官网下载:http://download.qt.io/archive/qt/ qt-opensource-linux-x64-5.8.0.run 这种类型是编译好的可以运行的x64位的i386的版本。 我们需要进入 single/ 内qt-everywhere-opensource-src-5.8.0.tar.xz 直接下载源码 我之前已经安装好了交叉编译工具 第二步 解压文件 找个英文目录,把qt-everywhere-opensource-src-5.8.0.tar.gz放进去。 用终端解压:tar -zxvf qt-everywhere-opensource-src-5.8.0.tar.gz 最好别右击“提取到此处”,这个解压好像和命令解压不同。 第三步: 修改编译配置文件: vim qt-everywhere-opensource-src-5.8.0/qtbase/mkspecs/linux-arm-gnueabi-g++/qmake.conf (注意我的改动) # # qmake configuration for building with arm-linux-gnueabi-g++ # MAKEFILE_GENERATOR = UNIX CONFIG += incremental QMAKE_INCREMENTAL_STYLE = sublib include(../common/linux.conf) include(../common/gcc-base-unix.conf) include(../common/g++-unix.conf) QT_QPA_DEFAULT_PLATFORM = linux #eglfs QMAKE_CFLAGS += -O2 -march=armv7-a QMAKE_CXXFLAGS += -O2 -march=armv7-a # modifications to g++.conf QMAKE_CC = arm-linux-gnueabi-gcc QMAKE_CXX = arm-linux-gnueabi-g++ QMAKE_LINK = arm-linux-gnueabi-g++ QMAKE_LINK_SHLIB = arm-linux-gnueabi-g++ # modifications to linux.conf QMAKE_AR = arm-linux-gnueabi-ar cqs QMAKE_OBJCOPY = arm-linux-gnueabi-objcopy QMAKE_NM = arm-linux-gnueabi-nm -P QMAKE_STRIP = arm-linux-gnueabi-strip load(qt_config) 注意: 这里指定了编译arm版qt所使用的编译器,与后期QtCreator项目的编译器是一样的。 如果你是用的是arm-none-linux-gnueabi-gcc,那么每一项都需要修改为arm-none-linux-gnueabi-。 #这里提前解释一下,第三步中已经指定好了编译器版本,所以第四步不需要指定了。 #第四步中的-xplatform linux-arm-gnueabi-g++是对应qmake.conf所在的文件夹,代表了编译的Qt库的版本。 第四步: 配置编译参数,用./configre -help 可以查看参数。 我的配置是(去除掉了一些用不到的选项): ./configure -release -opensource -confirm-license -xplatform linux-arm-gnueabi-g++ -prefix /usr/local/qt5.8-nomake examples -no-opengl -no-iconv -silent -qpa linuxfb -no-gtk -qt-libjpeg -qt-libpng 注意: 1、-xplatform linux-arm-gnueabi-g++ ,指定了编译Arm版的QT库; 2、-prefix后面的配置为qt库需要安装的位置,这个需要根据你的安装位置自己指定。(如果不指定默认的安装位置是 /usr/local/Qtxxx) 第五步: 如果上面配置没有问题,接下来make: $make 或者 $make -j2 /CPU 几个核可以使用“-j几”,核多编的快*/ 第六步: 安装:$sudo make install 在这里加sudo是因为,安装时会将库文件复制到上面第四步配置的安装目录( /usr/local/qt5.8)。 usr目录是需要root权限的。 好了,这是编译Qt5.8.0的过程。 编译平台插件: 由于Qt5以后,删除了嵌入式的QWS(Qt windows system-Qt窗体系统)换成QPA(Qt Platform Abstration -Qt平台抽象),平台插件在qt-everywhere-opensource-src-5.8.0/qtbase/src/plugins/platforms/下面。 有各种平台的插件,基于frambuffer的插件是lunuxfb这个文件夹下,其他的还有android、ios、winrt、windows等等,需要什么平台的编译就是了。
2017年-12月-7日
13174 阅读
0 评论
QT学习之路
2017-11-27
QT之MYSQL数据库操作要点
平台是基于Windows 10 x64、QT 5.8.0 编译环境 数据库操作要点 注意数据库 1.要将mysql中 mysql\libmysql.dll文件复制到\Qt\Qt5.8.0\5.8\mingw53_32\bin中 2. // 打开MySQL QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); //需要打开那个数据库,必须选择驱动 db.setHostName("localhost"); //查看帮助文档 db.setDatabaseName("mydata"); db.setUserName("root"); db.setPassword(""); 3.
2017年-11月-27日
6021 阅读
1 评论
QT学习之路
2015-11-26
QT实例3文本编辑器
QT实例3文本编辑器 第一步, 创建工程添加一个TextEdit 文本编辑框 选中MainWindow然后Ctrl+L垂直布局 输入 文件(&F) 第二步:设置munuBar 中Action的对象名 newAction openAction saveAction saveAsAction separator 分割符rintActiioon exitAction 查找 QAction类中的SIGNAL 信号 选择其中的触发函数 void triggered(bool checked =false); 第三步加上 第三步 查找QFile类的方法 setFileName QTODevice 中的属性 查找QFileDialog 利用静态方法调用Static Public Members getOpenFileName getSaveFileName QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),"/home",tr("Images (*.png*.xpm*.jpg)")); tr("Images (*.png*.xpm*.jpg)") 后续步骤直接看代码 头文件 mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QMessageBox> //对话框头文件 #include <QtDebug> //打印部分调试信息 #include <QFile> //文件处理类库 #include <QFileDialog> //文本对话框 #include <QDir> //文本目录 #include <QTextStream> //文本输出流 #include <QPrintDialog> //文件打印对话框 #include <QFontDialog> //字体对话框 #include <QFont> //字体本身的类 #include <QColor> //颜色的类 #include <QColorDialog> //颜色对话框 #include <QDateTime> //时间类 #include <QUrl> //网页链接的类 #include <QDesktopServices> //用于访问桌面服务的类 #include <about.h> //about Dialog对话框的头文件 #include <QCloseEvent> //当程序需要被关闭所需要处理的内容 所有的事件都是受保护的成员 namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); protected: void closeEvent(QCloseEvent *); private: Ui::MainWindow *ui; QString saveFileName; private slots: void newFileSlot(); void openFileSlot(); //打开一个已经存在的文本文件 void saveAsFileSlot(); void saveFileSlot(); //保存 void printFileSlot(); void setFontSlot(); //设置字体 void setColorSlot(); //设置颜色 void setDateTimeSlot(); //获得当前系统时间,并且打印出来 void aboutWebsiteSlot(); //打开主页 通过QDesktop void aboutSoftwareSlot(); }; #endif // MAINWINDOW_H2 mainwindow.cpp #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->setWindowTitle("文本编辑器"); //文件菜单 QObject::connect(ui->newAction,SIGNAL(triggered()),this,SLOT(newFileSlot())); QObject::connect(ui->openAction,SIGNAL(triggered()),this,SLOT(openFileSlot())); QObject::connect(ui->saveAction,SIGNAL(triggered()),this,SLOT(saveFileSlot())); QObject::connect(ui->saveAsAction,SIGNAL(triggered()),this,SLOT(saveAsFileSlot())); QObject::connect(ui->printAction,SIGNAL(triggered()),this,SLOT(printFileSlot())); QObject::connect(ui->exitAction,SIGNAL(triggered()),this,SLOT(close())); //编辑菜单 QObject::connect(ui->undoAction,SIGNAL(triggered()),ui->textEdit,SLOT(undo())); QObject::connect(ui->redoAction,SIGNAL(triggered()),ui->textEdit,SLOT(redo())); QObject::connect(ui->copyAction,SIGNAL(triggered()),ui->textEdit,SLOT(copy())); QObject::connect(ui->pasteAction,SIGNAL(triggered()),ui->textEdit,SLOT(paste())); QObject::connect(ui->cutAction,SIGNAL(triggered()),ui->textEdit,SLOT(cut())); QObject::connect(ui->selectAction,SIGNAL(triggered()),ui->textEdit,SLOT(selectAll())); QObject::connect(ui->fontAction,SIGNAL(triggered()),this,SLOT(setFontSlot())); QObject::connect(ui->colorAction,SIGNAL(triggered()),this,SLOT(setColorSlot())); QObject::connect(ui->datetimeAction,SIGNAL(triggered()),this,SLOT(setDateTimeSlot())); //帮助 QObject::connect(ui->aboutWebsiteAction,SIGNAL(triggered()),this,SLOT(aboutWebsiteSlot())); QObject::connect(ui->aoubtSoftwareAction,SIGNAL(triggered()),this,SLOT(aboutSoftwareSlot())); } MainWindow::~MainWindow() { delete ui; } void MainWindow::closeEvent(QCloseEvent *event) { //event->ignore(); //event->accept(); if(ui->textEdit->document()->isModified()) { QMessageBox msgBox; //显示的文本 msgBox.setText("文件内容已经被改变了"); //你想要做的操作 msgBox.setInformativeText("是否保存?"); //对话框中的button msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Save); int ret = msgBox.exec(); //QDialog中继承 exec switch (ret) { case QMessageBox::Save: // Save was clicked this->saveFileSlot(); break; case QMessageBox::Discard: // Don't Save was clicked event->accept(); break; case QMessageBox::Cancel: // Cancel was clicked event->ignore(); break; default: // should never be reached break; } } else { event->accept(); } } void MainWindow::newFileSlot() { //判断当前的文本编辑框中的doucument是否被改变 if(ui->textEdit->document()->isModified()) { //调试 qDebug()<<"current file modified!"; this->saveAsFileSlot(); } else { //调试 qDebug()<<"current flie no modified!"; ui->textEdit->clear(); this->setWindowTitle("无标题-文本编辑器");//设置标题提示新建的文件 } } void MainWindow::openFileSlot() { //获得fileName /* QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "/home",默认打开路径 tr("Images (*.png *.xpm *.jpg)")); */ saveFileName=QFileDialog::getOpenFileName(this,"打开文件",QDir::currentPath(),tr("TEXT (*.txt)")); // qDebug() << fileName; //判断文件选择是否被取消了 if(saveFileName.isEmpty()) { QMessageBox::information(this,"错误信息","请选择一个文件!"); return; } else { //创建一个新的文件对象 QFile * file = new QFile; //设置新建文件对象的文件名 file->setFileName(saveFileName); //打开文件file 已QIODevice方式 只读 返回值bool判断是否打开 bool ok=file->open(QIODevice::ReadOnly); if(ok) { //关联文件与文本流 QTextStream in(file); //in.readAll()将file中的所有的文件全部读进去 然后将所有文件全部setTet到textEdit ui->textEdit->setText(in.readAll()); this->setWindowTitle(saveFileName+"-文本编辑器"); file->close(); delete file; } else { //提示打开错误信息 QMessageBox::information(this,"错误信息","打开文件失败!"); return; } } } void MainWindow::saveFileSlot() { if(saveFileName.isEmpty()) { //qDebug()<<"无文件名"; this->saveAsFileSlot(); } else { //qDebug()<<"有文件名"; QFile *file =new QFile; file->setFileName(saveFileName); bool ok=file->open(QIODevice::WriteOnly); if(ok) { //将file和文本流相关联 QTextStream out(file); //转换成纯文本存入磁盘 out<<ui->textEdit->toPlainText(); file->close(); delete file; } } } void MainWindow::saveAsFileSlot() { QString saveFileName= QFileDialog::getSaveFileName(this,"保存文件",QDir::currentPath(),tr("TEXT (*.txt)")); if(saveFileName.isEmpty()) { QMessageBox::information(this,"错误信息","请选择一个存放位置!"); return; } QFile *file =new QFile; file->setFileName(saveFileName); bool ok=file->open(QIODevice::WriteOnly); if(ok) { //将file和文本流相关联 QTextStream out(file); //转换成纯文本存入磁盘 out<<ui->textEdit->toPlainText(); file->close(); this->setWindowTitle(saveFileName+"-文本编辑器"); delete file; } else { QMessageBox::information(this,"错误信息","保存失败!"); return; } } void MainWindow::printFileSlot() { //QPrintDialog } void MainWindow::setFontSlot() { //获得用户选择的字体 /* bool ok; QFont font = QFontDialog::getFont( &ok, QFont("Helvetica [Cronyx]", 10), this); if (ok) { // the user clicked OK and font is set to the font the user selected } else { // the user canceled the dialog; font is set to the initial // value, in this case Helvetica [Cronyx], 10 } */ bool ok; QFont font =QFontDialog::getFont(&ok,this); if(ok) { ui->textEdit->setFont(font); } else { QMessageBox::information(this,"错误信息","设置字体失败!"); return; } } void MainWindow::setColorSlot() { /* void Dialog::setColor() { QColor color; if (native->isChecked()) color = QColorDialog::getColor(Qt::green, this); else color = QColorDialog::getColor(Qt::green, this, "Select Color", QColorDialog::DontUseNativeDialog); if (color.isValid()) { colorLabel->setText(color.name()); colorLabel->setPalette(QPalette(color)); colorLabel->setAutoFillBackground(true); } } */ QColor color=QColorDialog::getColor(Qt::red,this); if(color.isValid()) { ui->textEdit->setTextColor(color); } else { QMessageBox::information(this,"错误信息","当前设置的颜色不可用"); return; } } void MainWindow::setDateTimeSlot() { //获取当前系统的时间到current对象中 QDateTime current=QDateTime::currentDateTime(); //以一定的时间格式转换成字符 QString time =current.toString("yyyy-M-dd hh::mm::ss"); //在文本框的末尾追加上textEdit ui->textEdit->append(time); } void MainWindow::aboutWebsiteSlot() { QDesktopServices::openUrl(QUrl("http://www.rainfly.cn")); } void MainWindow::aboutSoftwareSlot() { about *dialog=new about; dialog->show(); //显示一个非模态对话框 //dialog.exec() 显示modal dialog } mianwindow.ui about.h #ifndef ABOUT_H #define ABOUT_H #include <QDialog> namespace Ui { class about; } class about : public QDialog { Q_OBJECT public: explicit about(QWidget *parent = 0); ~about(); private slots: void on_pushButton_clicked(); private: Ui::about *ui; }; #endif // ABOUT_H about.cpp #include "about.h" #include "ui_about.h" about::about(QWidget *parent) : QDialog(parent), ui(new Ui::about) { ui->setupUi(this); this->setWindowTitle("关于软件"); } about::~about() { delete ui; } void about::on_pushButton_clicked() { this->close(); } about.ui main.cpp #include "mainwindow.h" #include <QApplication> #include <QTextCodec> int main(int argc, char *argv[]) { QApplication a(argc, argv); //将QString转换成UTF-8 编码 解决中文乱码问题 QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); MainWindow w; w.show(); return a.exec(); }
2015年-11月-26日
11033 阅读
1 评论
QT学习之路
2015-11-26
QT实例2 四则运算器
四则运算器 第一步画好ui 更改控件对象名称 下拉列表框ConBobox选择输入多个Item 后面可以根据Item的index排序 来监测用户选择的项 第二步 完成以下代码 mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include<QMessageboBox> //后面需要使用到对话框操作 namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT //元对象编译器 public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: //元对象编译器自动声明的槽 void on_pushButton_clicked(); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H mainwindow.cpp #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } //click()槽实现函数 void MainWindow::on_pushButton_clicked() { //通过QLineEdit的类中方法text()获得单行文本框的String值 //通过QString类的方法toInt();将QString的值转换成对应的Int型整数 int int1=ui->lineEdit->text().toInt(); int int2=ui->lineEdit_2->text().toInt(); int int_result; //获取控件下拉列表框的项 索引值 switch(ui->comboBox->currentIndex()) { case 0: int_result=int1+int2; break; case 1: int_result=int1-int2; break; case 2: int_result=int1*int2; break; case 3: if(int2==0) { QMessageBox::warning(this,"Error Message","Second Can't be Zero!"); return; } int_result=int1/int2; break; //控件只定义了4个Item 所以不会有default default: break; } //通过QString类中number()方法将int型转换成QString类型 然后在文本框输出出来! ui->lineEdit_3->setText(QString::number(int_result)); //弹出对话框窗口 MessageboBox 输出结果 QMessageBox::information(this,"Result:",QString::number(int_result)); } 测试输入 1/0 查询提示结果 12312
2015年-11月-26日
7701 阅读
0 评论
QT学习之路
2015-11-25
QT实例1 打开程序
打开一个程序实例 第一步 画好设计ui 第二步 选择submitPushButton 右击 go to slot 选择clicked() 编写函数 第三步 函数体解析 QTcreator 自动添加槽声明 添加头文件 QProcess QProcess *myProcess = new QProcess(parent); //产生一个myProcess 然后调用start方法 启动此程序! myProcess->start(program, arguments); 在cmdLineEdit 单行文本框中取出文件 头文件查找QLineEdit 获得取文本函数text(); QString::trimmed () const QString str = " lots\t of\nwhitespace\r\n "; str = str.trimmed(); 函数去除字符串后的空格 // str == "lots\t of\nwhitespace" #include "mainwindow.h" #include "ui_mainwindow.h" #include <QProcess> #include <QString> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); //初始submitButton 不可以使用 ui->submitPushButton->setEnabled(false); //固定窗口大小 this->setMaximumSize(400,250); this->setMinimumSize(400,250); //LineEdit控件中textEdited的方法获得是否在输入字符! QObject::connect(ui->cmdLineEdit,SIGNAL(textEdited(QString)),this,SLOT(setButtonEnableSlot(QString))); //连接comLinedeit发出的信号监测Enter键是否按下,this对象的槽产生on_pushButton_clicked();操作! QObject::connect(ui->cmdLineEdit,SIGNAL(returnPressed()),this,SLOT(on_pushButton_clicked())); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { //new一个新的进程对象 QProcess *process = new QProcess; //ui上面的LineEdit的text()方法获取QString文本 QString startProgram=ui->cmdLineEdit->text(); //利用trimmed()去除QString startProgarm后面含有的空格 process->start(startProgram.trimmed()); ui->cmdLineEdit->clear(); //清空cmdLineDdit this->close(); //关闭窗体 } void MainWindow::setButtonEnableSlot(QString) { ui->submitPushButton->setEnabled(true); //打开submitButton按钮 }
2015年-11月-25日
11285 阅读
0 评论
QT学习之路
2015-11-22
自定义槽(QT基础知识)
部件编译快捷 F3 信号槽编辑快捷键 F4 Ctrl + R 编译运行 Shift +Alt +R 模拟运行ui Ctrl + H 水平布局 Ctrl + L 垂直布局 定义和声明之间的切换快捷键 F4 实现自定义槽的两种方法 第一种 1.写好槽的声明(接口)和实现 // coustom slots private slots: void changeTitleSlot(); void MainWindow::changeTitleSlot() { this->setWindowTitle("Hello World!"); } 2.完成conect //链接槽 QObject::connect(ui->changeTitleButton,SIGNAL(clicked()),this,SLOT(changeTitleSlot())); //当前changeTitleButton发送一个SIGNAL(clicked())的信号 至this 要求此类行为SLOT(changeTitleSlot()) 第二种 在button右键选择转到槽(go to slot) 自动添加声明和实现函数 函数体部分直接完成即可 无需链接! 优先选用第一种!
2015年-11月-22日
10482 阅读
1 评论
QT学习之路
2015-11-21
搭建QT编译环境
开始学习QT开发,首先需要搭建QT开发环境,我选择的是QT4.8.5的开发环境 虽然已经有很多新版本了,首先下载 1. qt-win-opensource-4.8.5-mingw.exe 2.qt-creator-windows-opensource-2.8.0.exe 3. MinGW-gcc440_1 下载地址:在最下方网盘内 以下安装默认路径全部全部将C:该为D:,because xxx; 第一步: 安装QT Creator运行qt-creator-windows-opensource-2.8.0.exe 下一步 安装路径D:\Qt\qtcreator-2.8.0 默认安装即可 第二步: 下载MinGW-gcc440_1解压至D:\QT\mingw根目录 (注意下面的QT4.8.5安装MinGW也同样改至D:\QT\mingw) 第三步: 安装qt-win-opensource-4.8.5-mingw.exe同样修改安装路径至D:\Qt\4.8.5 第五步 添加环境变量 (如何添加请百度) Path内容中增加两项 D:\Qt\4.8.5\bin; D:\Qt\qtcreator-2.8.0\bin; 如果舍去此步骤debug产生的.exe文件无法运行 qmake命令将无法找到显示不是内部命令 第六步 链接QTcreator和QT4.8.5 打开QTcreator 选择工具->选项 ->构建和运行->QT版本 ->添加(如图) 打开QTcreator 选择工具->选项 ->构建和运行->编译器 ->添加(如图) 测试是否安装完成 在开始菜单中选择Qt 4.8.5 Command Prompt 程序 在F:\hello\main.cpp 文件中写入以下代码 #include<QApplication> #include<QLabel> int main(int argc,char **argv) { QApplication app(argc,argv); QLabel *label =new QLabel; label ->setText("Hello world"); label ->show(); return app.exec(); } 切换至 f:\hello 盘 在DOS中输入命令 qmake -project //创建一个project qmake //QT编译 mingw32-make //生成Windows 应用程序 在debug文件夹下 hello.exe //运行hello.exe 当出现hello world完成QT开发环境搭建 可以运行但是无法调试错误解决办法 Debugging starts Debugging has failed Debugging has finished 原因:Qt Creator 3.5.1需要更新版本的GDB。从http://qt-project.org/wiki/QtCreatorBuildGdb 下载qtcreator-gdb-7.4-MINGW32_NT-6.1-i686,解压后放到MinGW目录下,让后从Qt Creator中 工具-》选项-》构建和运行-》Debuggers 选项选择MinGW目录中的gdb-i686-pc-mingw32.exe即可 百度网盘:QT 提取码:rs54
2015年-11月-21日
12373 阅读
0 评论
QT学习之路