/*****************Qt显示中文(主要在main函数实现)***************************/#include <QTextCodec>   // 编码头文件QTextCodec::setCodecForCStrings(QTextCodec::codecForName("gb18030"));// 窗口里面可以接收或写中文文字// 这个和上面那个是等级的 QTextCodec::setCodecForLocale(QTextCodec::codecForName("gb18030"));QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030"));// 窗口部件里(如button)可以中文显示  int main(int argc, char *argv[]) { QApplication app(argc, argv); QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030"));QTextCodec::setCodecForCStrings(QTextCodec::codecForName("gb18030"));QWidget *pWidget = new QWidget; QLabel label(pWidget); label.setText(QObject::tr("同一个世界,同一个梦想")); // 或label.setText("同一个世界,同一个梦想");pWidget->show(); return app.exec();}QApplication::setQuitOnLastWindowClosed(false);// 后台运行,按关闭按钮关闭不了/***************************主窗口操作***********************************************/// 设置屏幕大小,这里固定为330*210this->setMinimumSize(330, 210);this->setMaximumSize(330, 210);this->setWindowIcon(QIcon(":/new/prefix1/QQ_PIC/Icon_1.ico"));// 主窗口设置icon, "……"为icon图片路径this->setWindowTitle("QQ2012-Qt版本");// 设置窗口的名字int w = this->width(); // 获取其宽度int h = this->height(); // 获取其高度QWidget *parent = this->parentWidget(); // 获得自己的父对象if (NULL != parent){}this->setWindowFlags(Qt::FramelessWindowHint);// 无边框/*****************文本编辑框TexiEdit(#include <QTextEdit>)*********************/ui->textEdit->setTextColor(Qt::red);  // 把显示的文字设置为红色ui->textEdit->setColor(QColor(0, 255, 0)); // 设置字体的另外一个方法,后面的值对应着R G Bui->textEdit->setText("hello, Qt!");// 在文本编辑框设置内容ui->textEdit->append("abc");// 另起一行追加“abc”ui->textEdit->setFontPointSize(20);// 设置字体大小,对后面的代码有效,前面的不能改变ui->textEdit->insertPlainText("333333");  // 开始“333333”QString str1 = ui->textEdit->toPlainText();// 获得textEdit的内容/******************随机时间(#include <QTime>)**************************/int rand = 0;qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));//以0时0分0秒到现在的秒数为种子, 调用全局的qrand()函数生成随机数rand = qrand()%10000;//对10000取余,保证位于10000的范围内/******************调色板的使用(#include <QPalette>)*********************/QPalette::Window, 通常指窗口部件的背景色QPalette::WindowText,通常指窗口部件的前景色QPalette::Base,指文本输入窗口部件的背景色QPalette::Text,指文本输入的窗口部件的前景色QPalette::Button,指按钮窗口部件的背景色QPalette::ButtonText,指按钮窗口的前景色QPalette p; // 定义对象p.setColor(QPalette::Window, Qt::blue); // Window为大写p.setColor(QPalette::WindowText, QColor(255, 0, 0));// 颜色设置的另外一种方式// 到第一步,调色板调好了ui->lcdNumber->setPalette(p); // 选择lcdNumber使用这个调试板ui->lcdNumber->setAutoFillBackground(true); // 自动填充背景色/*********************按钮操作(#include <QPushButton>)****************************/QPushButton *buttonSet; // 对象指针buttonSet = new QPushButton("设置", this);// 为对象分配空间,并设置内容buttonSet->setGeometry(15, 185, 75, 22);// 设置button的位置大小ui->pushButton->setGeometry(QRect(0,0,100,100));// 设置button位置大小ui->pushButton->setGeometry(0,0,100,100);// 设置button位置大小的另一种方法ui->pushButton->setText("Ensure");// 设置按钮内容qDebug()<<"button text = "<<ui->pushButton->text();// 获取button里的内容ui->pushButton->setIcon(QIcon("../image/on.png"));// 设置button里的iconui->pushButton->setIconSize(QSize(50,50));// 设置icon的大小ui->pushButton->resize(100,50);// 重新设置button的大小 qDebug()<<__FILE__<<__LINE__;// 打印文件名和所在行数int pw = ui->pushButton->width();// 获取宽和高的两种方式int ph = ui->pushButton->height();int x = ui->pushButton->geometry().x();int y = ui->pushButton->geometry().y();ui->pushButton->move(100,100); // 移动button的位置ui->pushButton->hide(); // 隐藏buttonui->pushButton->show(); // 显示buttonui->pushButton->setEnabled(false); // button不使能ui->pushButton->setEnabled(true); // button使能/**********************按下button的操作***************************/QString msg = this->sender()->objectName();// 按下button时,获取button的名字,假如名字为“abc”,获取信号发出者的名字QPushButton *button; // 定义一个指针对象button = (QPushButton *)this->sender();// 确定哪个按钮被按下,并接收这个信号的发出者,最好先判断button是否为空,不为空才操作msg += "######"+ button->text();// 字符串连接,button->text()为获取button里面的内容,如内容为“123” ui->labelDisplay->setText(msg);// 在label显示出来,结果为:abc######123int Num = this->sender()->objectName().at(10).digitValue();// 假如名字为toolButton1, at(10)就指向1了,这字符就转化为数字/**********************字符串处理(#include <QString>)*********************************/QString str = "123";bool OK;int m = str.toInt(&OK,16);// 字符串转整型, 16表示“123”里面的数字是16进制,10就为10进制,操作成功后,OK返回truestr = QString::number(m);// 整型转换成字符串str.append("abc"); // 追加str += "hello"; // 追加的另外一种方式QString str2;str2 = QString("**%1##%2&&%3").arg(123).arg("!!!!").arg(“654”);// 组包相当于sprintf,结果为123!!!!654 /***********************标签操作(#include <QLabel>)***************************************/// 操作和pushButton差不多labelImage = new QLabel(this);// 为label分配一个空间,也可以同时添加名字,操作和pushButton一样labelImage->setGeometry(QRect(0, 180, 330, 30));// 设置label的位置labelImage->setPixmap(QPixmap(":/new/prefix1/QQ_PIC/qq3.jpg"));// 在label上设置图片ui->labelImage->setScaledContents(true);// 图片自动适应label大小ui->labelImage->setText("hello Qt world");// 设置label里的内容QFont font; // 需要头文件(#include <QFont>)font.setPointSize(10); // 设置大小ui->labelImage->setFont(font); // label设置字体大小ui->labelImage->setText(QString("Mike"));// 设置label内容的另外一种方式QString test = ui->labelImage->text();              // 获得label里面的内容ui->labelImage->show(); // 显示labelthis->showFullScreen(); // 全屏显示ui->labelImage->resize(20, 20); // 改变label的大小/************************************combobox(#include <QComboBox>)*****************************************/comboBoxAccount = new QComboBox(this);// 为combobox分配空间comboBoxAccount->setGeometry(95, 90, 115, 20);// 设置位置comboBoxAccount->setEditable(true);// 设置状态为可编辑的comboBoxAccount->insertItem(0, "1234567");// 在第0行(通常所说的第一行)插入内容comboBoxAccount->insertItem(1, "231435353");// 在第1行(通常所说的第二行)插入内容ui->comboBox->setCurrentIndex(0);// 显示第0行的内容QString currText = ui->comboBox->currentText();// 获取combobox当前的内容int index = ui->comboBox->currentIndex();// 换取当前的索引号/***************************************行编辑(#include <QLineEdit>)**************************************************/lineEditPassword = new QLineEdit(this); // 分配空间lineEditPassword->setGeometry(95, 115, 115, 20); // 设置位置lineEditPassword->setEchoMode(QLineEdit::Password);// 状态设置为密码模式ui->lineEdit->setText("aaaaaa"); // 设置内容ui->lineEdit->insert("bbbbbb"); // 插入内容QString str = ui->lineEdit->text(); // 获取内容/*************************************checkBox(#include <QCheckBox>)***********************************************/checkBoxRemQQ = new QCheckBox("记住密码", this); // 分配空间checkBoxRemQQ->setGeometry(95, 150, 70, 20); // 设置位置if( ui->checkBoxRemQQ->isChecked()) // 判断是否按下qDebug()<<"checkBoxRemQQ is Checked";/***********************动画操作(#include <QMovie>)********************************/movie = new QMovie;movie->setFileName("../image/boy.gif");// 设置gif动画,“……”为图片路径// 或者QMovie *movie = new QMovie("../boom.gif");ui->label->setScaledContents(true); // 自适应大小ui->label->setMovie(movie); // 在label设置动画movie->start(); // 开启动画/****************数码管操作(#include <QLCDNumber>)**********************/ui->lcdNumber->setDigitCount(5); // 设置数码管显示5个数字ui->lcdNumber->setNumDigits(5);  // 等价上面ui->lcdNumber->display("ABC"); // 让数码管显示内容/************************进度条操作(#include <QProgressBar>)*******************************/   ui->progressBar->setMinimum(0); // 设置进度条的最小值ui->progressBar->setMaximum(200); // 设置进度条的最大值ui->progressBar->setValue(99); // 在进度条所占的比例,并显示出来/***********************************布局操作******************************************/QPushButton *button;this->button.setParent(this);  // 用this不易出错, 指定父对象,this->button.setText("click me!"); // 设置button内容ui->horizontalLayout->addWidget(&button);// 将部件加到水平布局管理器ui->verticalLayout->addWidget(&button);  // 将部件加到垂直布局管理器ui->gridLayout->addWidget(&button, 1, 1, 1, 1);// 将部件加到网格布局管理器/************************************定时器操作(#include <timer>)***********************************************//********************* 在构造函数里定义*********************************/QTimer *timer = new QTimer();// 括号里加不加this都可以// 定时器start之后每隔1s发送一个timeout()信号,每隔1S会执行一次mySlot()槽函数connect(timer, SIGNAL(timeout()), this, SLOT(mySlot() ));timer->start(1000);// 以ms为单位,启动定时器,此次即为1秒/***************************槽函数mySlot()的处理********************************/static count = 11; // 静态变量,count的值每次改变都记录下来count--; // 10,9,8,7……倒计ui->lcdNumber->display(count); // 在lcd上显示if (0 == count){timer->stop(); // 关闭定时器ui->lcdNumber->hide(); // 隐藏LCDui->label->show(); // 显示labelthis->showFullScreen(); // 全屏显示ui->label->movie()->start();// 动画启动}/**********************信号和槽的使用(两个ui切换)**********************************/// 两个ui,分别为mainWidgt, secondaryWidgt,其中mainWidgt为主界面,界面对应类的名字和ui名字相同// secondaryWidgt类中声明信号signals:void goBack();// 在mainWidgt类,定义一个secondaryWidgt的指针对象 *w, 接着在其构造函数操作this->w = new  secondaryWidgt; // 分配空间// 信号和槽连接,当接收到secondaryWidgt发出goBack()信号,就显示mainWidgt窗口this->connect(w, SIGNAL(goBack()), this, SLOT(show())); // mainWidgt窗口按下按钮时,隐藏自己(this->hide()),显示secondaryWidgt窗口(w->show())// secondaryWidgt窗口按下按钮时,隐藏自己(this->hide()),发送goBack()信号(emit this->goBack())/**********************************常用对话框的使用************************************************/// 通过按钮按下发出信号,在对应的槽函数处理/***********************文件操作(#include <QFileDialog>)*******************************/QString str;str = QFileDialog::getOpenFileName(this, "MyOpenFile", "../","debug (*.o *.cpp);;txtFile(*.txt);;All File(*.*)");// "MyOpenFile"为打开新窗口的名字, "../"为文件打开的上级路径// "debug (*.o *.cpp);;txtFile(*.txt);;All File(*.*)"为文件打开的格式// str接收的是打开文件的路径/********************************颜色设定(#include <QColorDialog>)********************************************/QColor mycolor;mycolor = QColorDialog::getColor(); // 获取颜色if ( false == corlor.isValid)// 判断颜色是否有效, 不加这个判断,颜色变回默认值return;QPalette palette; // 画笔palette.setColor(QPalette::Base, mycolor); // 设置颜色// 设置颜色的另外一种方式QBrush brush(mycolor); // 使用颜色palette.setBrush(QPalette::Active, QPalette::Base, brush); // 使用笔刷ui->colerLineEdit->setPalette(palette); // 用画笔画/************************字体设置(#include <QFontDialog>)**********************************************/bool ok = false;QFont font = QFontDialog::getFont(&ok); // 得到字体if(true == ok) // 如果字体有效,防止字体恢复成默认值ui->fontLineEdit->setFont(font); // 设置字体/************************常用对话框(#include <QMessageBox>)*****************************************************//**********************询问**********************************/int button = QMessageBox::question(this,"MyQuestion", "Are you OK?",QMessageBox::No | QMessageBox::Yes| QMessageBox::Cancel);switch(button){case QMessageBox::No:ui->label->setText("NO");break;case QMessageBox::Yes:ui->label->setText("Yes");break;case QMessageBox::Cancel:ui->label->setText("Cancel");break;/*********************信息对话框*****************************/QMessageBox::information(this, "my information", "Game over");/*********************警告对话框******************************/QMessageBox::warning(this, "my Warning", "Your system have a serious problem !!\nIt Will turn off in 3 min.");/************************************************常用事件处理**********************************************//**************************************鼠标点击事件(#include <QMouseEvent>)*************************************/void mouseMoveEvent ( QMouseEvent * e );void mousePressEvent ( QMouseEvent * e );void mouseReleaseEvent ( QMouseEvent * e );void mouseDoubleClickEvent( QMouseEvent * e );// 鼠标移动事件, 默认是按下移动才启动事件void Widget::mouseMoveEvent(QMouseEvent *e)// 事件函数名字必须这样,不能改变,因为这个是虚函数  ui->label->setText("("+QString::number(e->x())+","+QString::number(e->y())+")");// 显示其坐标// 要想不需要按下移动,也能启动事件,在构造函数里加下面的函数this->setMouseTracking(true);// 鼠标点击事件void Widget::mousePressEvent(QMouseEvent *e)QString s="";if(e->button()==Qt::LeftButton) // 左击{s  = "LeftButton Pressed\n";}    if(e->button()==Qt::RightButton) // 右击{s  = "RightButton Pressed\n";}if(e->button()==Qt::MidButton) // 中间滑轮点击{s = "MidButton Pressed\n";}// 鼠标释放事件,操作和点击一样void Widget::mouseReleaseEvent(QMouseEvent *e)// 滑轮滚动事件void Widget::wheelEvent(QWheelEvent *e)QString s;if(e->orientation()== Qt::Vertical)// 判断滚轮是否垂直滚动{if(e->delta()>0) // 大于0为滚轮向上s += " go (head)";else // 小于0即为向下s += " go (back)";}/*******************************键盘事件(#include <QKeyEvent>)*************************************/// 修饰键操作void MykeyEvent::keyPressEvent(QKeyEvent *e)QString s = "";switch(e->modifiers()){ // 修饰键选择,可以达到Ctrl+A这样的效果case Qt::ControlModifier: // Ctrl键s = tr("Ctrl+");break;case Qt::AltModifier: // Alt键s = tr("Alt+");break;}switch(e->key()) // 普通按键{case Qt::Key_Left: // 方向键的向左s += tr("Left_Key Press");break;case Qt::Key_Right: // 方向键的向右s += tr("Rigth_Key Press");break;case Qt::Key_Up: // 方向键的向上s += tr("Up_Key Press");break;case Qt::Key_Down: // 方向键的向下s += tr("Down_Key Press");break;case Qt::Key_Z: // Z键s += tr("Z_Key Press");break;}ui->label->setText(tr(s.toAscii()));// 转化为ASCII码,再显示// 主窗口大小发生变化时被调用void MykeyEvent::resizeEvent(QResizeEvent *e)qDebug()<<"new size = "<<e->size(); // 变化后的窗口大小qDebug()<<"old size = "<<e->oldSize(); // 变化前的窗口大小/*****************************绘图事件(#include <QPaintEvent>)********************************/// 利用QPainter绘制各种图形,在Void paintEvent(QPaintEvent *event)中实现// 当窗口被绘制时被调用,也可以通过update()产生paintEvent(……)事件// 绘制的内容以背景的形式出现在窗口中,QPainter 一般要放在paintEvent()里,否则会初始化失败event->rect()  --- 可得到需要重新绘制的区域QPainter painter(this); --- 创建对象painter.setPen(); --- 设置画笔painter.setBrush() --- 设置画刷patiner.drawXXX(); --- 画drawPoint()         画点drawLine() 画直线drawRect() 画矩形drawEllipse() 画椭圆drawPicture() 画图片drawImage() 绘图片drawPixmap() 绘图片drawText() 绘文本// 绘图事件void PaintEvent::paintEvent(QPaintEvent * event)qDebug()<< event->rect(); // 运行结果为:QRect(0,0 400x300)QPainter p(this); // 创建画笔对象,需要头文件#include <QPainter>QPen pen; // #include <QPen>,创建一支画笔,下面是配置画笔pen.setColor(Qt::red); // 画笔的颜色pen.setStyle(Qt::DashDotDotLine); // 画笔画线的类型,虚线pen.setWidth(3); // 画笔画线的宽度p.setPen(pen); // 把画笔交给画家画p.drawLine(10,10,260,10); // 以(10, 10)为起点,以(260, 10)为终点,画直线p.drawRect(10,20,200,150);  // 以(10, 20)为起点,宽为200, 高为150, 画矩形QBrush brush; // 创建画刷,在上面刷东西,需要头文件#include <QBrush>brush.setColor(Qt::magenta); // 设置颜色,粉红色brush.setStyle(Qt::DiagCrossPattern); // 画刷的风格,网格风格p.setBrush(brush); // 装画刷交给画家p.drawRect(10,20,200,150); // 以(10, 20)为起点,宽为200, 高为150的矩形里面刷东西p.setPen(QPen()); // 画笔恢复默认值p.setBrush(QBrush()); // 画刷恢复默认值p.drawEllipse(230,30,150,200);  // 以(230, 30)为起点,宽为150, 高为200的矩形画内切圆p.setBrush(QBrush(QPixmap("../image/test.jpg"))); // 画刷里面的内容是图片p.drawPixmap(0, 0, this->width(), this->height(), QPixmap("../image/on.png")); // 以窗口大小画图// 画图事件调用update()会使整个窗口的图片刷新,不要再绘图事件调用update(),播放动画,设置button的图片// 设置字体QFont font; // 需要头文件#include <QFont>font.setFamily("幼圆"); // 设置字体类型font.setPointSize(30); // 设置字体大小font.setBold(true); // 是否加粗font.setUnderline(true); // 是否加下划线font.setStrikeOut(true); // 设置横穿文字中间的线p.setFont(font); // 把字体交给画家p.setPen(Qt::red); // 设置画笔颜色p.drawText(20, 190, "你好,Qt!"); // 在(20, 190)为起点,写字// 这和绘图事件无关,截图QPixmap image = QPixmap::grabWidget(this, 0, 0, this->width(), this->height());image.save("1.png");    // 保存图片/********************************播放音乐(#include <QSound>)*************************************/// 一种方法QSound::play("mysounds/bells.wav");// 另一种方法QSound bells("mysounds/bells.wav");bells.play();// 也就是说QSound *bells = new QSound("mysounds/bells.wav");bells->play();bells->setLoops(-1); // 无限循环/***************************枚举的使用************************************/// 首先在一个类中定义一个枚举,如下class A{public:enum B{Empty, Black, White};};// 在类中的成员函数了,可以直接操作,如:B c = Empty;// 假如在别的类中,创建类A的对象指针a, 如 a = new A(this);// 这里有两种使用方法A::B test = a->Black;A::B test = A::Black;/********************************文件夹操作(#include <QDir>)************************************/QDir tempDir;   // 文件夹变量QString str = QCoreApplication::applicationDirPath(); //获取当前应用程序路径(#include <QCoreApplication>)str += "/outputImage";if (false == tempDir.exists(str))   // 当这个文件夹不存在时,才创建{bool ok = tempDir.mkdir(str);// 循环创建,直到成功创建while (false == ok){ok = tempDir.mkdir(str);}}/******************************文件操作(#include <QFile>)********************************/// 写操作QFile file("1.txt"); // 创建文件对象//一般不要IO_ReadWrite,很容易出现赃数据//如果要在文件的后面添加内容要IO_WriteOnly|IO_Append//如果要清空原来的内容,只要IO_WriteOnlyif(file.open(QIODevice::WriteOnly)) // 只写方式打开文件{QTextStream out(&file);out.setCodec(QTextCodec::codecForName("gb18030")); // 写之前设置编码out << i << "
"<<"image"<<"
" << Label[i]->x() << "
"<<Label[i]−>y()<<"
"<< Label[i]->width() << "
"<<Label[i]−>height()<<"
"<< *this->picPath[i]<< "$$"<< this->cardBackgound << "\n";file.close();}// 读操作QFile file(fileTempPath);QString dataLine;// 只读方式打开if (file.open(QIODevice::ReadOnly)){QTextStream readData(&file);readData.setCodec(QTextCodec::codecForName("gb18030")); // 读之前也设置编码while (false == readData.atEnd())    // 是否是到文件的结尾{dataLine = readData.readLine();  // 先读一行if (dataLine.size() != 1){this->flag = dataLine.section("
",0,0).toInt();//坐标下标this−>data[flag][0]=dataLine.section("
", 2, 2).toInt();  // xthis->data[flag][1] = dataLine.section("
",3,3).toInt();//ythis−>data[flag][2]=dataLine.section("
", 4, 4).toInt();  // wthis->data[flag][3] = dataLine.section("$$", 5, 5).toInt();  // h}}file.close();}// 宏定义#define print qDebug()<<__FILE__<<__LINE__<<":"/************************memcpy的使用**********************************/// 函数的原型:void  *memcpy(void *dest,   const void *src,   size_t count); int directioncpy[8][2] = {{0,-1},{1,-1},{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1}};int direction[8][2];// 函数的功能是将directioncpy的内容拷贝到direction// sizeof(int)*16,注意这个长度memcpy(direction,directioncpy,sizeof(int)*16);int chessHistroy[64][8][8];int chess[8][8]; memcpy(chessHistroy[histroy],chess,sizeof(int)*64);/*******************设置按钮背景色**************************/
setStyleSheet("background-color: rgb(255, 255, 0)");/************重写鼠标事件******************/
QPoint dragPosition;     // 在类中增加这一个成员void Widget::mouseMoveEvent(QMouseEvent *e)
{if(e->buttons() & Qt::LeftButton){ //当满足鼠标左键被点击时move(e->globalPos()-this->dragPosition); //移动窗口}
}
void Widget::mousePressEvent(QMouseEvent *e)
{if(e->button() == Qt::LeftButton)  //点击左边鼠标{//globalPos()获取根窗口的相对路径,frameGeometry().topLeft()获取主窗口左上角的位置,// frameGeometry().topLeft()相当于起点坐标: this->x(), this->y();this->dragPosition=e->globalPos()-this->frameGeometry().topLeft();    // 和下面操作等价的// this->dragPosition.setX(e->x());// this->dragPosition.setY(e->y());//qDebug() << this->frameGeometry().topLeft();  // 等价下面//qDebug() << this->x() << "," << this->y();//qDebug() << e->globalPos();    // 等价下面//qDebug() << e->x()+x() << ","  << e->y()+y();}else if(e->button() == Qt::RightButton){this->close();}
}/*************************QStringList*********************************/QStringList list("hello");qDebug()<<list; // ("hello")//追加list.append("word");qDebug()<<list; //("hello", "word")list<<"qt"<<"listen";qDebug()<<list; // ("hello", "word", "qt", "listen")//合并QString str;str = list.join(",");qDebug()<<str;  // "hello,word,qt,listen"//拆分str = "hello,word,,qt";QStringList list1;list1 = str.split(",");qDebug()<<list1; // ("hello", "word", "", "qt")//去掉空格list1 = str.split(",",QString::SkipEmptyParts);qDebug()<<list1; // ("hello", "word", "qt")//索引int num;num = str.indexOf(QRegExp("o"));qDebug()<<"num = "<<num; // num =  4num = list1.indexOf(QRegExp("hello"));qDebug()<<"QStringList list1 = "<<num; // QStringList list1 = 0num = str.lastIndexOf(QRegExp("o"));qDebug()<<"last num = "<<num; // last num =  7num = list1.lastIndexOf(QRegExp("hello"));qDebug()<<"last QStringList = "<<num; //last QStringList =  0//替换 ("hello", "word", "qt", "listen")list.replaceInStrings("o","eee");qDebug()<<"replace list = "<<list;// ("helleee", "weeerd", "qt", "listen")list.replace(2,"replace");qDebug()<<"replace only one list = "<<list;// ("helleee", "weeerd", "replace", "listen")//过滤 ("hello", "word", "qt")QStringList result;result = list1.filter("o");qDebug()<<"filter result = "<<result; // ("hello", "word")//查找if(list1.contains("hello")) // trueqDebug()<<"true";

QT常用函数总结(全)相关推荐

  1. 百科不全书之QT常用函数

    参考链接: 璎珞qc:Qt之QImage类. 沙振宇:Qt输出打印信息的日志到文件(两种方式). tandesir:Qt测算程序运行时间. 半生瓜のblog [QT]QT容器 百科不全书之QT常用函数 ...

  2. QT:常用函数详解--常用操作记录(个人笔记)

    QT:常用函数详解(个人笔记) PS:一下内容个人笔记,要求自己看懂,随笔,阅读体验会很差很差! Qt setContentsMargins()函数 函数原型:void QLayout::setCon ...

  3. 史上最全的PHP常用函数大全,不看看你就out了(还会不断更新哦!)

    纪录了PHP的一些常用函数和函数代码!不要错过了哦. PHP的一些常用函数 usleep() 函数延迟代码执行若干微秒. unpack() 函数从二进制字符串对数据进行解包. uniqid() 函数基 ...

  4. Qt QString类及常用函数功能详解

    QString 是 Qt 编程中常用的类,除了用作数字量的输入输出之外,QString 还有很多其他功能,熟悉这些常见的功能,有助于灵活地实现字符串处理功能. QString 存储字符串釆用的是 Un ...

  5. Qt creator常用快捷键退出全屏与进入全屏

    Qt creator常用快捷键退出全屏与进入全屏 Qt creator界面全屏后退出全屏 CTRL+SHIFT+F11 Qt creator进入全屏界面(此时无关闭的❌) CTRL+SHIFT+F11

  6. opencv常用函数,QT中Mat与QImage的转换

    一.opencv简介 opencv是一个跨平台计算机视觉和机器学习软件库,可以运行在Linux.Windows.Android和Mac OS操作系统上,实现了图像处理和计算机视觉方面的很多通用算法. ...

  7. QT中关于窗口全屏显示与退出全屏的实现

    近期在学习QT时遇到了很多问题这也是其中一个,个人通过在各种书籍和网络上的查阅找到了一些关于这方面的答案,希望能给大家一些帮助. 首先,在QT中对于窗口显示常用的有这么几个方法可以调用: Qt全屏显示 ...

  8. Qt常用控件介绍(一)

    Qt常用控件介绍 Qt Creator 的使用技巧 Qt Creator的常用快捷键 按钮 QPushButton QToolButton QRadioButton QCheckBox QComman ...

  9. PHP副本保存用什么函数,PHP_收藏的PHP常用函数 推荐收藏保存,内容: 复制代码 代码如下: lt - phpStudy...

    收藏的PHP常用函数 推荐收藏保存 内容: 复制代码 代码如下: function GetIP() { //获取IP if ($_SERVER["HTTP_X_FORWARDED_FOR&q ...

最新文章

  1. 又有两所一流高校加入“不返校”阵营,非毕业年级学生,开学时间待定!
  2. 马斯克的星辰大海,还在继续。“月球电梯,我来啦”
  3. hdoj-1715-大菲波数(大斐波那契数列)
  4. 以主干开发作为持续交付的基础
  5. linux用avk怎么提取字符,在Linux下进行视频音频格式转换提取等
  6. JavaScript面向对象——理解构造函数继承(类继承)
  7. 使用git checkout命令切换到指定的commit
  8. Lombok–您绝对应该尝试一下
  9. 第 1-6 课:玩转时间 + 面试题
  10. 弹窗实用素材模板|UI设计中的弹窗设计技巧,快get
  11. JAVA对象内存分配过程
  12. Spark Streaming ReceiverTracker架构设计
  13. JDBC与数据库连接池
  14. 设计模式学习书籍推荐(设计模式书籍你读过哪几本)
  15. VS2017 Git操作教程
  16. c语言求圆锥的表面积和体积_c语言问题,输入圆锥的半径和高,得出表面积和体积。请问程序该如何改....
  17. android q mix3,Android Q+5G 小米MIX3现场播放8K视频:画面流畅
  18. TCP 与 CPU 架构发展史
  19. PDF文件不能编辑,有什么办法能够解决?
  20. 中国人民大学与加拿大女王大学金融硕士宋会芝:只要开始就不晚

热门文章

  1. 数据仓库(3)数仓建模之星型模型与维度建模
  2. 爬虫大作业_爬取三星Galaxy_S9论坛
  3. vue - vue中使用西瓜播放器xgplayer
  4. BurnInTest测试固态硬盘详解
  5. LRTimelapse Pro Mac(延时摄影软件) v5.1.1破解版
  6. python 使用API并将获取到的数据可视化的基本方法(详细)
  7. python 游戏大作_使用requests和beautifulsoup爬取3DM单机大作排行榜
  8. 为什么电脑计算机里没有桌面,为什么电脑开机后桌面上什么都没有?
  9. 13 个优秀的 Vue 开源项目及合集推荐
  10. 企业为什么要做等保?不做等保有什么后果?