【发布时间】:2013-12-04 03:22:22
【问题描述】:
我最近在阅读elementary OS 杂志,偶然发现了这篇文章,The Heuristics of Headerbars。它谈到了新的GTK HeaderBar widget,以及它对设计和用户体验的所有好处。我想知道,对于 Qt/QML,这样的事情可能吗?
【问题讨论】:
我最近在阅读elementary OS 杂志,偶然发现了这篇文章,The Heuristics of Headerbars。它谈到了新的GTK HeaderBar widget,以及它对设计和用户体验的所有好处。我想知道,对于 Qt/QML,这样的事情可能吗?
【问题讨论】:
http://qt-project.org/doc/qt-4.8/stylesheet.html
http://qt-project.org/doc/qt-4.8/stylesheet-syntax.html
http://qt-project.org/doc/qt-4.8/stylesheet-reference.html
http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qframe
http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qmenubar
我希望系统托盘菜单更易于导航,点击精度较低,我最终使用了这个:
m_tray_menu->setStyleSheet(
"QMenu {"
"background-color: white;"
"margin: 10px;"
"}"
"QMenu::item {"
"padding: 2px 25px 2px 20px;"
"margin: 10px;"
"border: 1px solid transparent;"
"font: 20px;"
"height: 50px;"
"width: 250px;"
"}"
"QMenu::item:selected {"
"border-color: black;"
"background: rgba(0, 255, 0, 150);"
"}"
);
所有 QML 的整个样式都使用类似的 css 样式语法或 qss,因为它有时在文档中被提及。
此外,如果您想摆脱桌面环境的窗口装饰,请使用 Qt Window Flags 和 Qt Widget Attributes,您可以随心所欲地制作任何东西。
http://qt-project.org/doc/qt-4.8/widgets-windowflags.html
http://qt-project.org/doc/qt-4.8/qt.html#WindowType-enum
http://qt-project.org/doc/qt-4.8/qt.html#WidgetAttribute-enum
例如:
MyWidget::MyWidget(QWidget * parent): QWidget(parent)
{
this->setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint);
this->setAttribute(Qt::WA_TranslucentBackground);
// this->setAttribute(Qt::WA_NoSystemBackground);// automatically set by previous attribute
}
希望对您有所帮助。
【讨论】: