📄 dzklist.ui.h
字号:
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**//****程希望****编的
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
using namespace std; //能用sort()//****程希望****编的
void DzkList::init()//****程希望****编的
{
loadText("savefile.txt");
// listViewSC.setSorting(1,false);
// listViewSC.setSorting(3,false);
}
void DzkList::outlstpbclickedSlot()////****程希望****编的
{
;
}
bool DzkList::loadText( const QString &fileName )//****程希望****编的
{
QFile file(fileName);
if(!file.open(IO_ReadOnly | IO_Translate)){
ioError(file,tr("Can not open file %1 for reading") );
return false;
}
QTextStream in(&file); //用那个能输出中文?
in.setEncoding(QTextStream:: Locale); //test: , Unicode Latin1 RawUnicode UnicodeUTF8
//in.setEncoding(QTPextCodec::Unicode);
while(!in.atEnd()){
savedStr = in.readLine();
QStringList fields = QStringList::split(",",savedStr);//最难是这if +static ,it will all display the first
bool ok;
int key=fields[1].toInt(&ok,10);
savedScore.push_back(key); //把key装到vector
if(ok){
QPair<QString,QString> p(fields[0],fields[2]);
ipss[key]=p;
}
}
stable_sort(savedScore.begin(),savedScore.end()); //use std::sort
QValueVector<int>::const_iterator it=savedScore.end();
while(it!=savedScore.begin()){
--it;
static int i=0;
QListViewItem *item = new QListViewItem(listViewSC, i>0 ? item : 0);//最难是这if +static ,it will only display once
item->setText( 0, tr(QString::number(i++)) );
item->setText( 1, trUtf8( (*( ipss.find(*it))).first ) ); //name
item->setText( 2, tr(QString::number(*it) ) ); //score
item->setText( 3, trUtf8( (*( ipss.find(*it))).second ) ); //date
//当超过10个时,会出现个毛病
}
if(file.status() !=IO_Ok){
ioError(file,tr("Error reading from file %1"));
return false;
}
return true;
}
void DzkList::error(const QFile &file, const QString &message)//****程希望****编的
{
QMessageBox::warning(0,tr("dzkdialog"),message.arg(file.name()));
}
void DzkList::ioError(const QFile &file, const QString &message)//****程希望****编的
{
error(file,message);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -