{"id":33,"date":"2025-05-19T17:03:47","date_gmt":"2025-05-19T09:03:47","guid":{"rendered":"http:\/\/112.74.48.51\/?p=33"},"modified":"2025-05-19T17:03:47","modified_gmt":"2025-05-19T09:03:47","slug":"qcombobox%e6%a0%b7%e5%bc%8f%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/look123.top\/index.php\/2025\/05\/19\/qcombobox%e6%a0%b7%e5%bc%8f%e8%a1%a8\/","title":{"rendered":"QComboBox\u6837\u5f0f\u8868"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>QComboBox QAbstractItemView::item {\n    height: 50px;   \/* \u9879\u7684\u9ad8\u5ea6\uff08\u8bbe\u7f6epComboBox->setView(new QListView());\u540e\uff0c\u8be5\u9879\u624d\u8d77\u4f5c\u7528\uff09 *\/\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\/* \u672a\u4e0b\u62c9\u65f6\uff0cQComboBox\u7684\u6837\u5f0f *\/\nQComboBox {\n    border: 1px solid gray;   \/* \u8fb9\u6846 *\/\n    border-radius: 3px;   \/* \u5706\u89d2 *\/\n    padding: 1px 18px 1px 3px;   \/* \u5b57\u4f53\u586b\u886c *\/\n    color: #000;\n    font: normal normal 15px \"Microsoft YaHei\";\n    background: transparent;\n}\n\n\/* \u4e0b\u62c9\u540e\uff0c\u6574\u4e2a\u4e0b\u62c9\u7a97\u4f53\u6837\u5f0f *\/\nQComboBox QAbstractItemView {\n    outline: 0px solid gray;   \/* \u9009\u5b9a\u9879\u7684\u865a\u6846 *\/\n    border: 1px solid yellow;   \/* \u6574\u4e2a\u4e0b\u62c9\u7a97\u4f53\u7684\u8fb9\u6846 *\/\n    color: green;\n    background-color: red;   \/* \u6574\u4e2a\u4e0b\u62c9\u7a97\u4f53\u7684\u80cc\u666f\u8272 *\/\n    selection-background-color: lightgreen;   \/* \u6574\u4e2a\u4e0b\u62c9\u7a97\u4f53\u88ab\u9009\u4e2d\u9879\u7684\u80cc\u666f\u8272 *\/\n}\n\n\/* \u4e0b\u62c9\u540e\uff0c\u6574\u4e2a\u4e0b\u62c9\u7a97\u4f53\u6bcf\u9879\u7684\u6837\u5f0f *\/\nQComboBox QAbstractItemView::item {\n    height: 50px;   \/* \u9879\u7684\u9ad8\u5ea6\uff08\u8bbe\u7f6epComboBox->setView(new QListView());\u540e\uff0c\u8be5\u9879\u624d\u8d77\u4f5c\u7528\uff09 *\/\n}\n\n\/* \u4e0b\u62c9\u540e\uff0c\u6574\u4e2a\u4e0b\u62c9\u7a97\u4f53\u8d8a\u8fc7\u6bcf\u9879\u7684\u6837\u5f0f *\/\nQComboBox QAbstractItemView::item:hover {\n    color: #FFFFFF;\n    background-color: lightgreen;   \/* \u6574\u4e2a\u4e0b\u62c9\u7a97\u4f53\u8d8a\u8fc7\u6bcf\u9879\u7684\u80cc\u666f\u8272 *\/\n}\n\n\/* \u4e0b\u62c9\u540e\uff0c\u6574\u4e2a\u4e0b\u62c9\u7a97\u4f53\u88ab\u9009\u62e9\u7684\u6bcf\u9879\u7684\u6837\u5f0f *\/\nQComboBox QAbstractItemView::item:selected {\n    color: #FFFFFF;\n    background-color: lightgreen;\n}\n\n\/* QComboBox\u4e2d\u7684\u5782\u76f4\u6eda\u52a8\u6761 *\/\nQComboBox QAbstractScrollArea QScrollBar:vertical {\n    width: 10px;\n    background-color: #d0d2d4;   \/* \u7a7a\u767d\u533a\u57df\u7684\u80cc\u666f\u8272*\/\n}\n\nQComboBox QAbstractScrollArea QScrollBar::handle:vertical {\n    border-radius: 5px;   \/* \u5706\u89d2 *\/\n    background: rgb(160,160,160);   \/* \u5c0f\u65b9\u5757\u7684\u80cc\u666f\u8272\u6df1\u7070lightblue *\/\n}\n\nQComboBox QAbstractScrollArea QScrollBar::handle:vertical:hover {\n    background: rgb(90, 91, 93);   \/* \u8d8a\u8fc7\u5c0f\u65b9\u5757\u7684\u80cc\u666f\u8272yellow *\/\n}\n\n\/* \u8bbe\u7f6e\u4e3a\u53ef\u7f16\u8f91\uff08setEditable(true)\uff09editable\u65f6\uff0c\u7f16\u8f91\u533a\u57df\u7684\u6837\u5f0f *\/\nQComboBox:editable {\n    background: green;\n}\n\n\/* \u8bbe\u7f6e\u4e3a\u975e\u7f16\u8f91\uff08setEditable(false)\uff09!editable\u65f6\uff0c\u6574\u4e2aQComboBox\u7684\u6837\u5f0f *\/\nQComboBox:!editable {\n     background: blue;\n}\n\n\/* \u8bbe\u7f6e\u4e3a\u53ef\u7f16\u8f91editable\u65f6\uff0c\u70b9\u51fb\u6574\u4e2aQComboBox\u7684\u6837\u5f0f *\/\nQComboBox:editable:on {\n    background: green;\n}\n\n\/* \u8bbe\u7f6e\u4e3a\u975e\u7f16\u8f91!editable\u65f6\uff0c\u70b9\u51fb\u6574\u4e2aQComboBox\u7684\u6837\u5f0f *\/\nQComboBox:!editable:on {\n     background: blue;\n}\n\n\/* \u8bbe\u7f6e\u4e3a\u53ef\u7f16\u8f91editable\u65f6\uff0c\u4e0b\u62c9\u6846\u7684\u6837\u5f0f *\/\nQComboBox::drop-down:editable {\n    background: lightblue;\n}\n\n\/* \u8bbe\u7f6e\u4e3a\u53ef\u7f16\u8f91editable\u65f6\uff0c\u70b9\u51fb\u4e0b\u62c9\u6846\u7684\u6837\u5f0f *\/\nQComboBox::drop-down:editable:on {\n    background: lightgreen;\n}\n\n\/* \u8bbe\u7f6e\u4e3a\u975e\u7f16\u8f91!editable\u65f6\uff0c\u4e0b\u62c9\u6846\u7684\u6837\u5f0f *\/\nQComboBox::drop-down:!editable {\n    background: lightblue;\n}\n\n\/* \u8bbe\u7f6e\u4e3a\u975e\u7f16\u8f91!editable\u65f6\uff0c\u70b9\u51fb\u4e0b\u62c9\u6846\u7684\u6837\u5f0f *\/\nQComboBox::drop-down:!editable:on {\n    background: lightgreen;\n}\n\n\/* \u70b9\u51fbQComboBox *\/\nQComboBox:on {\n}\n\n\/* \u4e0b\u62c9\u6846\u6837\u5f0f *\/\nQComboBox::drop-down {\n    subcontrol-origin: padding;   \/* \u5b50\u63a7\u4ef6\u5728\u7236\u5143\u7d20\u4e2d\u7684\u539f\u70b9\u77e9\u5f62\u3002\u5982\u679c\u672a\u6307\u5b9a\u6b64\u5c5e\u6027\uff0c\u5219\u9ed8\u8ba4\u4e3apadding\u3002 *\/\n    subcontrol-position: top right;   \/* \u4e0b\u62c9\u6846\u7684\u4f4d\u7f6e\uff08\u53f3\u4e0a\uff09 *\/\n    width: 15px;   \/* \u4e0b\u62c9\u6846\u7684\u5bbd\u5ea6 *\/\n\n    border-left-width: 1px;   \/* \u4e0b\u62c9\u6846\u7684\u5de6\u8fb9\u754c\u7ebf\u5bbd\u5ea6 *\/\n    border-left-color: darkgray;   \/* \u4e0b\u62c9\u6846\u7684\u5de6\u8fb9\u754c\u7ebf\u989c\u8272 *\/\n    border-left-style: solid;   \/* \u4e0b\u62c9\u6846\u7684\u5de6\u8fb9\u754c\u7ebf\u4e3a\u5b9e\u7ebf *\/\n    border-top-right-radius: 3px;   \/* \u4e0b\u62c9\u6846\u7684\u53f3\u4e0a\u8fb9\u754c\u7ebf\u7684\u5706\u89d2\u534a\u5f84\uff08\u5e94\u548c\u6574\u4e2aQComboBox\u53f3\u4e0a\u8fb9\u754c\u7ebf\u7684\u5706\u89d2\u534a\u5f84\u4e00\u81f4\uff09 *\/\n    border-bottom-right-radius: 3px;   \/* \u540c\u4e0a *\/\n}\n\u3000\/* \u8d8a\u8fc7\u4e0b\u62c9\u6846\u6837\u5f0f *\/\n\u3000QComboBox::drop-down:hover {\n\u3000\u3000\u3000background: yellow;\n\u3000}\n\/* \u4e0b\u62c9\u7bad\u5934\u6837\u5f0f *\/ \nQComboBox::down-arrow \n{\u3000\u3000width: 15px; \/* \u4e0b\u62c9\u7bad\u5934\u7684\u5bbd\u5ea6\uff08\u5efa\u8bae\u4e0e\u4e0b\u62c9\u6846drop-down\u7684\u5bbd\u5ea6\u4e00\u81f4\uff09 *\/ \u3000\u3000\n    background: transparent; \/* \u4e0b\u62c9\u7bad\u5934\u7684\u7684\u80cc\u666f\u8272 *\/ \u3000\u3000padding: 0px 0px 0px 0px; \/* \u4e0a\u5185\u8fb9\u8ddd\u3001\u53f3\u5185\u8fb9\u8ddd\u3001\u4e0b\u5185\u8fb9\u8ddd\u3001\u5de6\u5185\u8fb9\u8ddd *\/\u3000\u3000\n    image: url(:\/images\/combobox_arrow_down.png); \n} \n    \n \/* \u70b9\u51fb\u4e0b\u62c9\u7bad\u5934 *\/      \nQComboBox::down-arrow:on \n{ \u3000\u3000\n    image: url(:\/images\/combobox_arrow_up.png); \/* \u663e\u793a\u4e0a\u62c9\u7bad\u5934 *\/ \n}\n\u00a0\n\u6ce8\u610f\uff1a\nint main()\n{\n\u3000\u3000QComboBox* pComboBox = new QComboBox(this);\n\u3000\u3000pComboBox->setView(new QListView());\u00a0\u00a0\u00a0\/\/\u6dfb\u52a0\u8fd9\u53e5\uff0c\u8bbe\u7f6e\u4e0b\u62c9\u5217\u8868\u9879\u9ad8\u624d\u80fd\u751f\u6548\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-33","post","type-post","status-publish","format-standard","hentry","category-cpp_qt"],"_links":{"self":[{"href":"https:\/\/look123.top\/index.php\/wp-json\/wp\/v2\/posts\/33","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/look123.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/look123.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/look123.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/look123.top\/index.php\/wp-json\/wp\/v2\/comments?post=33"}],"version-history":[{"count":1,"href":"https:\/\/look123.top\/index.php\/wp-json\/wp\/v2\/posts\/33\/revisions"}],"predecessor-version":[{"id":34,"href":"https:\/\/look123.top\/index.php\/wp-json\/wp\/v2\/posts\/33\/revisions\/34"}],"wp:attachment":[{"href":"https:\/\/look123.top\/index.php\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/look123.top\/index.php\/wp-json\/wp\/v2\/categories?post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/look123.top\/index.php\/wp-json\/wp\/v2\/tags?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}