//在main函数中加载qss文件 QFile file(QDir::currentPath() + "/ui.qss"); if (file.open(QFile::ReadOnly)) { QString stylesheet = QLatin1String(file.readAll()); qApp->setStyleSheet(stylesheet); file.close(); } else { QMessageBox::warning(NULL, "warning", "openfailed",QMessageBox::Yes | QMessageBox::No,QMessageBox::Yes); }