Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt 使用滑块连接combox_Qt_Slider_Qwt_Qcombobox - Fatal编程技术网

Qt 使用滑块连接combox

Qt 使用滑块连接combox,qt,slider,qwt,qcombobox,Qt,Slider,Qwt,Qcombobox,我正在尝试连接一个带有qwtslider的qcombobox,我在combox上有两个选项,mm和pixel。选择该选项时,我想将比例更改为像素或彩信。我已经创建了一些用作插槽的函数,它们是: void planevolume::mm() { ui->Slider->setRange(xmin, xmax/(256/3), 1.0/(256/3)); ui->Slider->setScale(xmin, (xmax+1)/(256/3), ((xm

我正在尝试连接一个带有qwtslider的qcombobox,我在combox上有两个选项,mm和pixel。选择该选项时,我想将比例更改为像素或彩信。我已经创建了一些用作插槽的函数,它们是:

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

我想你是想在你的
currentindexpix
currentIndexMM
函数中使用
setCurrentIndex()
而不是
currentIndex()
,就像我得到了
planevolume::currentindexpix()的多个定义和
planevolume::currentIndexMM()的多个定义一样“我试过使用void-activated(int-index)和void-currentindexchange(int-index),但我发现它们是受保护的……我想我会使用两个按钮,因为我认为这会使我的工作更容易。你提到的受保护的成员是信号。我只会在有currentIndex(1)的地方使用setCurrentIndex(1)。虽然我对你的connect声明有点困惑。