Qt QComboBox下拉框文字重叠解决方法

如果QComboBox下拉框文字重叠,在设置好样式之后,在后面加 setView(new QListView())即可;

 m_comboRate = new QComboBox();
    m_comboRate->setFixedSize(700,74);
    m_comboRate->setStyleSheet(QString("QComboBox{border: 1px solid #949494;border-radius:5px;"
                             "font-family:MicrosoftYaHei;font-size:30px;color:#333333;}"
                              "QComboBox QAbstractItemView{border: 0px;outline:0px;"
                              "selection-background-color: #26409b;height:100px;font:30px;}"
                             "QComboBox::drop-down {width: 60px;border-left-width: 0px;"
                              "border-left-color: gray;border-left-style: solid;"
                             "image: url(%1);}"
                           "QComboBox::down-arrow:hover{image:url(%2);}").arg(SKINPATH+"/pull.png").arg(
                                 SKINPATH+"/pull_checked.png"));
    m_comboRate->setView(new QListView());

 

1、设置样式:
边框色、选项高度、下拉按钮图标
network_type
->setStyleSheet("QComboBox{border:1px solid gray;}" "QComboBox QAbstractItemView::item{height:20px;}" //下拉选项高度 "QComboBox::down-arrow{image:url(:/icon/arrowdown);}" //下拉箭头 "QComboBox::drop-down{border:0px;}"); //下拉按钮 network_type->setView(new QListView());

 

posted @ 2019-03-19 16:52  cicero  阅读(2868)  评论(0编辑  收藏  举报