使用qt写程序,总要有界面,而美工给程序猿的设计总是那么美轮美奂,那么该怎么样将效果图转化为实际图?
qt借鉴css经验,设计出自己的qss。
拿实例说话吧:
1、
QPushButton#evilButton { background-color: red }
2、
QPushButton#evilButton {
background-color: red;
border-style: outset;
border-width: 2px;
border-color: beige;
}
3、
QPushButton#evilButton {
background-color: red;
border-style: outset;
border-width: 2px;
border-radius: 10px;
border-color: beige;
font: bold 14px;
min-width: 10em;
padding: 6px;
}
不知你看出区别了没有,也不知你看到他的用处没有。 如果没有那么这里一定有你想要的:
推荐1: http://thesmithfam.org/blog/2009/09/10/qt-stylesheets-tutorial/
推荐2: http://qt-project.org/doc/qt-4.7/stylesheet-examples.html
推荐3: http://qt-project.org/doc/qt-4.8/stylesheet-reference.html
qcolor颜色名称:
qframe结构图:
例子一:
background-color: red;
border-style: outset;
border-width: 2px;
border-radius: 10px;
border-color: beige;
font: bold 14px;
min-width: 10em;
padding: 6px;
例子二:
QPushButton:pressed {
background-color: rgb(0, 224, 0);
border-style: inset;
}
QPushButton:hover {
background-color: rgb(0, 224, 240);
border-style: inset;
}
鼠标没有经过按钮时:
鼠标经过时:
伪目标:
Pseudo-StateDescription:active 激活时
:adjoins-item This state is set when the ::branch of a QTreeView is adjacent to an item.
:alternate 多选择
:bottom 底部
:checked 选择状态
:closable 可关闭
:closed 关闭状态
:default 默认
:disabled 无效状态
:editable 可编辑的
:edit-focus The item has edit focus (See QStyle::State_HasEditFocus). This state is available only for Qt Extended applications.
:enabled The item is enabled.
:exclusive The item is part of an exclusive item group. For example, a menu item in a exclusiveQActionGroup.
:first The item is the first (in a list). For example, the first tab in a QTabBar.
:flat The item is flat. For example, a flat QPushButton.
:floatable The items can be floated. For example, the QDockWidget has theQDockWidget::DockWidgetFloatable feature turned on.
:focus The item has input focus.
:has-children The item has children. For example, an item in a QTreeView that has child items.
:has-siblings The item has siblings. For example, an item in a QTreeView that siblings.
:horizontal The item has horizontal orientation
:hover The mouse is hovering over the item.
:indeterminate The item has indeterminate state. For example, a QCheckBox or QRadioButton ispartially checked.
:last The item is the last (in a list). For example, the last tab in a QTabBar.
:left The item is positioned at the left. For example, a QTabBar that has its tabs positioned atthe left.
:maximized The item is maximized. For example, a maximized QMdiSubWindow.
:middle The item is in the middle (in a list). For example, a tab that is not in the beginning or theend in a QTabBar.
:minimized The item is minimized. For example, a minimized QMdiSubWindow.
:movable The item can be moved around. For example, the QDockWidget has theQDockWidget::DockWidgetMovable feature turned on.
:no-frame The item has no frame. For example, a frameless QSpinBox or QLineEdit.
:non-exclusive The item is part of a non-exclusive item group. For example, a menu item in a non-exclusive QActionGroup.
:off For items that can be toggled, this applies to items in the "off" state.
:on For items that can be toggled, this applies to widgets in the "on" state.
:only-one The item is the only one (in a list). For example, a lone tab in a QTabBar.
:open The item is in the open state. For example, an expanded item in a QTreeView, or aQComboBox or QPushButton with an open menu.
:next-selected The next item (in a list) is selected. For example, the selected tab of a QTabBar is next tothis item.
:pressed The item is being pressed using the mouse.
:previous-selected The previous item (in a list) is selected. For example, a tab in a QTabBar that is next tothe selected tab.
:read-only The item is marked read only or non-editable. For example, a read only QLineEdit or anon-editable QComboBox.
:right The item is positioned at the right. For example, a QTabBar that has its tabs positionedat the right.
:selected The item is selected. For example, the selected tab in a QTabBar or the selected item in aQMenu.
:top The item is positioned at the top. For example, a QTabBar that has its tabs positioned atthe top.
:unchecked The item is unchecked.
:vertical The item has vertical orientation.
:window The widget is a window (i.e top level widget)
原文:http://blog.csdn.net/cgzhello1/article/details/8514113
http://blog.csdn.net/cgzhello1/article/details/8516024