1 //在main函数中加载qss文件
 2 QFile file(QDir::currentPath() + "/ui.qss");
 3 if (file.open(QFile::ReadOnly))
 4 {
 5     QString stylesheet = QLatin1String(file.readAll());
 6     qApp->setStyleSheet(stylesheet);
 7     file.close();
 8 } 
 9 else
10 {
11     QMessageBox::warning(NULL, "warning", "openfailed",QMessageBox::Yes | QMessageBox::No,QMessageBox::Yes);
12 }