如题
------解决方案--------------------
class QStyle
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Qt contains a set of QStyle subclasses that emulate the styles of the different platforms supported by Qt (QWindowsStyle, QMacStyle, QMotifStyle, etc.). By default, these styles are built into the QtGui library. Styles can also be made available as plugins.
Qt's built-in widgets use QStyle to perform nearly all of their drawing, ensuring that they look exactly like the equivalent native widgets. The diagram below shows a QComboBox in eight different styles.
------解决方案--------------------
xp系统当然是xp风格。
windows7下就是这几个风格可用:
("Windows", "WindowsXP", "WindowsVista", "Motif", "CDE", "Plastique", "Cleanlooks")
一般的main.cpp如下:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
增加两行:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
qDebug() << QStyleFactory::keys();//输出可用风格,帖子第三行的内容
a.setStyle(QStyleFactory::create("Windows"));// 修改默认风格。
w.show();
return a.exec();
}
------解决方案--------------------
lz说的意思是Qt的风格么?如果是Qt的风格的话,可以在main.cpp文件,添加:
- C/C++ code
#include <QMotifStyle> //这里的风格可以自己选择