例子1
//初始化demo的窗口,以后要用,请将demopage重写
QList<
CPageBase*>
t_list;
for(
int
i=
0;i<
12;i++)
{
CPageDemo
*p_demo
=
new
CPageDemo(
this);
QString
str
=
QString(
"Page
%1").arg(i+
1);
p_demo->setPageName(str);
p_demo->setButtonProperty(
":/on_widgets/Resources/communication.png",str);
m_pageMap.insert(p_demo->
p_pageButton,p_demo);
connect(p_demo->
p_pageButton,
SIGNAL(released()),
this,
SLOT(slotChangePage()));
p_stacked->addWidget(p_demo);
t_list.append(p_demo);
}
//转换成功返回"Y"否则返回"N"
QString result_str = result?QString("%1").arg("Y"):QString("%1").arg("N");
QTableWidgetItem *result_item = new QTableWidgetItem(result_str);
ui->file_list->setItem(row_idx, 1, result_item);
例子2
QStringList
files
=
QFileDialog::getOpenFileNames(
this,
tr(
"选择文件"),
".",
"CPP
Files
(*.h
*.cpp
)
|
Text
Files
(*.txt)
|
All
Files
(*.*)");
if(files.isEmpty())
{
return;
}
fill_items(files);
ui->
file_list->resizeColumnsToContents();例子3
QString
fileName
=
rx.cap().remove(
"title
mb-bg\"
title=").remove(
">");
rx.setPattern( "<div class=\"cut_intro\" style=\"overflow:hidden;\">[^<]{1,1000}<"); rx.indexIn(str); QString fileInfo = rx.cap( 0).remove( "<div class=\"cut_intro\" style=\"overflow:hidden;\">").remove( "<");
rx.setPattern( "<div class=\"wraper-info\">.{1,1000}<ul class=\"tags-share\">"); rx.indexIn(str); QString content = rx.cap().remove( "<div class=\"wraper-info\">").remove( "<ul class=\"tags-share\">");
QString send = QString( "<li>资源名: ") + fileName+ "</li>" + QString( "<li>资源简介:") + fileInfo+ "</li>" + content; send.remove( '\n');
rx.setPattern( "http://download.net/index.php/source/do_download/[^\"]{1,100}\""); rx.indexIn(str);
QString postUrl = rx.cap().remove( "\"");
rx.setPattern( "<div class=\"cut_intro\" style=\"overflow:hidden;\">[^<]{1,1000}<"); rx.indexIn(str); QString fileInfo = rx.cap( 0).remove( "<div class=\"cut_intro\" style=\"overflow:hidden;\">").remove( "<");
rx.setPattern( "<div class=\"wraper-info\">.{1,1000}<ul class=\"tags-share\">"); rx.indexIn(str); QString content = rx.cap().remove( "<div class=\"wraper-info\">").remove( "<ul class=\"tags-share\">");
QString send = QString( "<li>资源名: ") + fileName+ "</li>" + QString( "<li>资源简介:") + fileInfo+ "</li>" + content; send.remove( '\n');
rx.setPattern( "http://download.net/index.php/source/do_download/[^\"]{1,100}\""); rx.indexIn(str);
QString postUrl = rx.cap().remove( "\"");
例子3
//使用自定义的setlog函数
CHelp::setLog(
QString(
"好吧,出现验证码了,您手动输入吧!!"));
void
CHelp::setLog(
const
QString
content){
//
加锁
QMutexLocker
locker(&
m_Mutex);
//
输出的日志前面添加时间
QString
str;
QDateTime
dateTime
=
QDateTime::currentDateTime();
str
=
dateTime.toString(
"hh:mm::s
");
g_pLineEdit->append(str
+
content);
//
产生随机数
qsrand(
QTime(
0,
0,
0).secsTo(
QTime::currentTime()));
QString
rand
=
"http://download.net/index.php/rest/tools/validcode/source_ip_validate/10.";
例子4
lab_UserInfo->setText(
QString(
"欢迎您:
%1
您当前分:
%2
分").arg(
m_Account).arg(
m_nIntegral));
例子5
p.start(
"cmd"
);
p.waitForStarted();
p.write(
QString
(
"date
%1-%2-%3\n"
).arg(year).arg(month).arg(day).toLatin1());
p.closeWriteChannel();
p.waitForFinished(
1000
);
p.
close
();QString
cmd
=
QString(
"date
%1%2%3%4%5.%6"
).arg(month).arg(day).arg(hour).arg(min).arg(year).arg(sec);
system(cmd.toLatin1());
system(
"hwclock
-w"
)