我正在尝试将 qcombobox 与 qwtslider 连接,并且我在组合框上有两个选项,毫米和像素。当我选择该选项时,我想将比例更改为像素或毫米。我创建了一些函数作为插槽工作,它们是:
void planevolume::mm()
{
ui->Slider->setRange(xmin, xmax/(256/3), 1.0/(256/3));
ui->Slider->setScale(xmin, (xmax+1)/(256/3), ((xmax+1)/16)/(256/3));
connect(ui->Slider, SIGNAL(valueChanged(double)), ui->lcdNumber, SLOT(display(double)));
}
void planevolume::pixel()
{
ui->Slider->setRange(xmin, xmax, 1.0);
ui->Slider->setScale(xmin, xmax+1, (xmax+1)/16);
connect(ui->Slider, SIGNAL(valueChanged(double)), ui->lcdNumber, SLOT(display(double)));
}
我想我可以使用来自连接盒的信号连接它们。我的连接框是这样的:
ui->comboBox->insertItem( 1, QString("pixel"));
ui->comboBox->insertItem( 2, QString("mm"));
他们创建了一个可供选择的插槽:
void planevolume::currentIndexPixel()
{
ui->comboBox->currentIndex(1);
}
void planevolume::currentIndexMM()
{
ui->comboBox->currentIndex(2);
}
他们像这样连接它:
connect(this, SIGNAL(currentIndexPixel()),ui->Slider, SLOT(pixel()));
connect(this, SIGNAL(currentIndexMM()),ui->Slider, SLOT(mm()));
但我收到这样的错误,我不确定我做错了什么:
error: no matching function for call to ‘QComboBox::currentIndex(int)’
/usr/include/qt4/QtGui/qcombobox.h:184: note: candidates are: int QComboBox::currentIndex() const