查看完整版本: [-- 关于QComboBox鼠标点击出现的问题 --]

QTCN开发网 -> Qt基础编程 -> 关于QComboBox鼠标点击出现的问题 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

lwei24 2021-02-01 17:41

关于QComboBox鼠标点击出现的问题

在使用QComboBox时,出现这个错误Attempt to bind non-signal QComboBox::currentIndexChanged(int)。请问为什么会报这个错呢?代码如下:

    m_comboBoxPro = new QComboBox(this);
    m_comboBoxPro->setStyleSheet("QComboBox{font-family:'SimHei';font-size:9; border:1px solid lightgray;}"
                                 "QComboBox QAbstractItemView::item {min-height: 16px;}"
                                 "QComboBox::drop-down{border-left-width: 1px;border-left-color: lightgray;border-left-style: solid; border-top-right-radius: 3px;border-bottom-right-radius: 3px;subcontrol-origin: padding;subcontrol-position: top right; width:20px;}"
                                 "QComboBox::down-arrow{image:url(:/res/pwd/arrowDown01.png)}"
                                 "QComboBox::down-arrow:hover{image:url(:/res/pwd/arrowDown01.png)}"
                                 "QComboBox::down-arrow:pressed{image:url(:/res/pwd/arrowDown01.png)}");
    m_comboBoxPro->addItem(QString("123"));
    m_comboBoxPro->addItem(QString("456"));
    QStyledItemDelegate *delegate = new QStyledItemDelegate(this);
    m_comboBoxPro->setItemDelegate(delegate);
    m_comboBoxPro->resize(this->width()*45/100, this->height()*7/100);
    m_comboBoxPro->move(this->width()*20/100, this->height()*40/100);
    connect(m_comboBoxPro, SLOT(currentIndexChanged(int)), this, SLOT(slotClickedComboBox(int)));

fsu0413 2021-02-01 19:30
第二个参数应该是signal 不是slot

lwei24 2021-03-09 09:34
fsu0413:第二个参数应该是signal 不是slot (2021-02-01 19:30) 

多谢楼主,我真是太粗心了


查看完整版本: [-- 关于QComboBox鼠标点击出现的问题 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled