当前位置: 首页 > news >正文

五百人建站网站站点建设中端口号的作用

五百人建站,网站站点建设中端口号的作用,百度爱采购官网,东莞高埗网站建设本文主要介绍了qt普通菜单样式、带选中样式、带子菜单样式、超过一屏幕菜单样式、自定义带有滚动条的菜单样式#xff0c; 先上图如下#xff1a; 1.普通菜单样式 代码#xff1a; m_pmenu new QMenu(this);m_pmenu-setObjectName(quoteListMenu); qss文…本文主要介绍了qt普通菜单样式、带选中样式、带子菜单样式、超过一屏幕菜单样式、自定义带有滚动条的菜单样式 先上图如下 1.普通菜单样式 代码 m_pmenu new QMenu(this);m_pmenu-setObjectName(quoteListMenu); qss文件: QMenu {background-color: #3b3c49;margin:0px;padding:0px; }QMenu::indicator {width: 31px;height:30px;background-color: #3b3c49;margin: 2px }QMenu::indicator:selected {background-color: #144675;margin: 2px }QMenu::indicator:disabled {background-color: #414141;margin: 2px }QMenu::item {color: #ffffff;height:24px;font:normal 14px;margin:0px;padding-left:12px;padding-right:41px; }QMenu::item:selected {color: #ffffff;background-color:#545563; }QMenu::item:disabled { color: #707070; background-color: #414141; }QMenu::indicator:checked {image:url(:/pic/tick.png); }/********/ QMenu#quoteListMenu {background: #3b3c49;margin-top: 8px;margin-bottom: 8px;padding: 0px; }QMenu#quoteListMenu::item {color: #ffffff;height: 24px;font-size: 14px;padding-left:12px;padding-right:50px;background-color: transparent; }QMenu#quoteListMenu::item:selected {color: #ffffff;background-color: #545563; }QMenu#quoteListMenu::item:disabled {color: #707070;background-color:#414141; }QMenu#quoteListMenu::icon {padding-left: 20px; }QMenu#quoteListMenu::indicator:selected {background-color: #144675;margin: 2px; } 2.带选中样式的菜单 代码 m_pmenu2 new QMenu(this);m_pmenu2-setObjectName(quoteListMenu2); qss文件 QMenu {background-color: #3b3c49;margin:0px;padding:0px; }QMenu::indicator {width: 31px;height:30px;background-color: #3b3c49;margin: 2px }QMenu::indicator:selected {background-color: #144675;margin: 2px }QMenu::indicator:disabled {background-color: #414141;margin: 2px }QMenu::item {color: #ffffff;height:24px;font:normal 14px;margin:0px;padding-left:12px;padding-right:41px; }QMenu::item:selected {color: #ffffff;background-color:#545563; }QMenu::item:disabled { color: #707070; background-color: #414141; }QMenu::indicator:checked {image:url(:/pic/tick.png); }/*--------------------*/ QMenu#quoteListMenu2 {background: #3b3c49;margin-top: 8px;margin-bottom: 8px;padding: 0px; }QMenu#quoteListMenu2::item {color: #ffffff;height: 24px;font-size: 14px;padding-left:30px;padding-right:50px;background-color: transparent; }QMenu#quoteListMenu2::item:selected {color: #ffffff;background-color: #545563; }QMenu#quoteListMenu2::item:disabled {color: #707070;background-color:#414141; }QMenu#quoteListMenu2::icon {padding-left: 10px; }QMenu#quoteListMenu2::indicator {width: 31px;height:30px;background-color: #3b3c49;margin: 2px }QMenu#quoteListMenu2::indicator:selected {background-color: #545563;margin: 2px }QMenu#quoteListMenu2::indicator:checked {image:url(:/pic/tick.png); }QMenu#quoteListMenu2::indicator:disabled {background-color: #414141;margin: 2px }3.带子菜单样式可以调整下拉按钮到边框的距离 代码 m_pmenu3 new QMenu(this);m_pmenu3-setObjectName(myArrowGap); qss文件 QMenu {background-color: #3b3c49;margin:0px;padding:0px; }QMenu::indicator {width: 31px;height:30px;background-color: #3b3c49;margin: 2px }QMenu::indicator:selected {background-color: #144675;margin: 2px }QMenu::indicator:disabled {background-color: #414141;margin: 2px }QMenu::item {color: #ffffff;height:24px;font:normal 14px;margin:0px;padding-left:12px;padding-right:41px; }QMenu::item:selected {color: #ffffff;background-color:#545563; }QMenu::item:disabled { color: #707070; background-color: #414141; }QMenu::indicator:checked {image:url(:/pic/tick.png); }/****************/ QMenu#myArrowGap {background-color: #545563;border: 1px solid #000000;margin:0px;padding:0px; }QMenu#myArrowGap::item {color: #ffffff;font:normal 12px;margin-left:0px;margin-right:10px;margin-top: 0px;margin-bottom: 0px;padding-top:5;padding-bottom:5;padding-left:12px;padding-right:41px; }QMenu#myArrowGap::item:hover {color: #FFFFBB;background-color:#545563; }QMenu#myArrowGap::item:selected {color: #FFFFBB;background-color:#545563; }QMenu#myArrowGap::item:disabled { color: #707070; background-color: #414141; } 说明下拉按钮距离右边距离通过设置margin-right:10px;实现 4.超过一屏幕菜单样式 代码1头文件添加 #include QtWidgets #include QStyleclass UProxyStyle : public QProxyStyle {Q_OBJECT int styleHint(StyleHint h, const QStyleOption *op Q_NULLPTR,const QWidget *w Q_NULLPTR, QStyleHintReturn *rd Q_NULLPTR) const{printf(UMenu::styleHint %d\n,h);switch(h){ case QStyle::SH_ScrollBar_LeftClickAbsolutePosition: return true;case QStyle::SH_ScrollBar_MiddleClickAbsolutePosition:return true;case QStyle::SH_ScrollBar_ScrollWhenPointerLeavesControl: return false;case QStyle::SH_Menu_Scrollable: return true;/*这一句是关键返回true表明支持*/ }return QProxyStyle::styleHint(h,op,w); } }; 代码2cpp中使用 m_pmenu new QMenu(this);//m_pmenu-setObjectName(myMenu);m_pmenu-setStyle(new UProxyStyle());connect(m_pmenu,QMenu::triggered,this,Dialog::slotTriggered); 说明当超过屏幕时会自动出现箭头 5.自定义带有滚动条的菜单样式(用QWidgetAction实现) 代码1listwidgetaction.h文件 #ifndef LISTWIDGETACTION_H #define LISTWIDGETACTION_H#include QWidgetAction #include QListWidget #include QObjectclass ListWidgetAction : public QWidgetAction {Q_OBJECTpublic:explicit ListWidgetAction(QWidget *parent);virtual ~ListWidgetAction();void AddString(QString strText, int id);void Clear();void SetRowHeight(int nHeight);void SetMaxHeight(int nMaxHeight);signals:void sigClickItem(int id);private slots:void slotListItemClicked(QListWidgetItem *item);private:QListWidget* m_pListWidget;int m_nRowHeight 20;int m_nMaxHeight -1;};#endif // LISTWIDGETACTION_H代码2listwidgetaction.cpp文件 #include listwidgetaction.h #include QScrollBarListWidgetAction::ListWidgetAction(QWidget *parent):QWidgetAction(parent) {m_pListWidget new QListWidget(parent);m_pListWidget-setSpacing(0);m_pListWidget-setContentsMargins(0,0,0,0);m_pListWidget-setFocusPolicy(Qt::NoFocus);m_pListWidget-setVerticalScrollMode(QListWidget::ScrollPerPixel);//设置为像素滚动m_pListWidget-verticalScrollBar()-setEnabled(false);m_pListWidget-setObjectName(ListWidgetAction);m_pListWidget-setSelectionMode(QAbstractItemView::SingleSelection);m_pListWidget-setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);m_pListWidget-setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);connect(m_pListWidget, QListWidget::itemClicked, this, ListWidgetAction::slotListItemClicked);setDefaultWidget(m_pListWidget); }ListWidgetAction::~ListWidgetAction() {}void ListWidgetAction::AddString(QString strText, int id) {QListWidgetItem *item new QListWidgetItem(strText);item-setData(Qt::UserRole, id);item-setSizeHint(QSize(-1, m_nRowHeight));item-setTextAlignment(Qt::AlignCenter);m_pListWidget-addItem(item);//int nCount m_pListWidget-count();int nRowHeight m_nRowHeight;int nTotalHeight nCount * nRowHeight 4;if(m_nMaxHeight ! -1){if(nTotalHeight m_nMaxHeight){nTotalHeight m_nMaxHeight;m_pListWidget-verticalScrollBar()-setEnabled(true);m_pListWidget-setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);}else{m_pListWidget-verticalScrollBar()-setEnabled(false);m_pListWidget-setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);}}m_pListWidget-setFixedHeight(nTotalHeight);}void ListWidgetAction::Clear() {m_pListWidget-clear();}void ListWidgetAction::SetRowHeight(int nHeight) {m_nRowHeight nHeight;}void ListWidgetAction::SetMaxHeight(int nMaxHeight) {m_nMaxHeight nMaxHeight;}void ListWidgetAction::slotListItemClicked(QListWidgetItem *item) {int id item-data(Qt::UserRole).toInt();emit sigClickItem(id);}代码3使用 //菜单m_pmenu2 new QMenu(this);m_pmenu2-setObjectName(myMenulist);// void Dialog::on_pushButton_2_clicked() {m_pmenu2-clear();ListWidgetAction * actionList new ListWidgetAction(this);actionList-SetRowHeight(20);actionList-SetMaxHeight(300);connect(actionList , ListWidgetAction::sigClickItem, this, Dialog::slotMenuClickItem);for(int i0; i25;i){QString ss;ss QString(菜单kkkkkkkk%1).arg(i);actionList-AddString(ss, i);}m_pmenu2-addAction(actionList);m_pmenu2-exec(QCursor::pos());}void Dialog::slotMenuClickItem(int id) {m_pmenu2-hide();int aa 0;aa; }说明这一种样式因为是QWidgetAction实现所以只支持这种最简单的文字样式 demo源码QT实战-qt菜单样式实现、自定义带滚动条的菜单实现
http://www.w-s-a.com/news/187526/

相关文章:

  • 网站顶部展出的大幅广告中建八局第二建设有限公司
  • 公众微信绑定网站帐号优秀中文网页设计
  • 如何做漫画赚钱的网站企业网站管理系统c
  • 安康公司网站制作搜狗网站
  • 太仓住房与城乡建设局网站注册推广赚钱一个80元
  • wordpress 网站生成app企业网站改版的好处
  • 广州建站服务怎么让客户做网站
  • 南京手机网站设计公司wordpress导航页
  • 娄底市建设网站app网站开发小程序
  • 刷粉网站推广免费网站建设找王科杰信誉
  • 投标建设用地是哪个网站微信小程序多少钱
  • 做玄幻封面素材网站我国数字经济报告
  • 手机网站返回跳转wordpress带颜色的文字
  • 微信群领券网站怎么做创意广告图片
  • 跟我一起做网站嘉兴做网站哪家好
  • 上海知名建站公司山东住房和建设庭网站
  • 深圳市城乡建设部网站首页平台设计方案怎么做
  • 深圳美食教学网站制作wordpress列表图显示标题
  • 怎么做网址导航网站沈阳高端做网站建设
  • 棋牌网站开发需要多少钱整网站代码 带数据 免费 下载
  • 网站建设 sql 模版猎头用什么网站做单
  • 河北保定建设工程信息网站wordpress 远程缓存
  • 手机网站开发之列表开发win7网站开发教程
  • 楚雄市住房和城乡建设局网站廊坊企业网站建设
  • 东莞规划局官方网站wordpress添加文章页不显示图片
  • 做企业网站要哪些人员百度商城网站建设
  • c语言软件开和网站开发区别多产品的网站怎么做seo
  • 收益网站制作移动互联网应用的使用情况表格
  • 专业的手机网站建设公司哪家好同城信息网站建设
  • 参与做网站的收获国外网站服务器建设