0

I'm trying to connect a qcombobox with a qwtslider, and I have two options on the combox, mm and pixel. I want to make the scale change to pixels or mms when I choose that option. I've created some functions to work as slots and those are:

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)));
}

and i thought i could connect them using a signal from the connect box. my connect box is this:

  ui->comboBox->insertItem( 1, QString("pixel"));
  ui->comboBox->insertItem( 2, QString("mm"));

And them creating a slot to choose:

void planevolume::currentIndexPixel()
{
    ui->comboBox->currentIndex(1);
}

void planevolume::currentIndexMM()
{
    ui->comboBox->currentIndex(2);
}

them connecting it like this:

connect(this, SIGNAL(currentIndexPixel()),ui->Slider, SLOT(pixel()));
connect(this, SIGNAL(currentIndexMM()),ui->Slider, SLOT(mm()));

but I'm getting the error like this, and I'm not sure what am I doing wrong:

error: no matching function for call to ‘QComboBox::currentIndex(int)’
/usr/include/qt4/QtGui/qcombobox.h:184: note: candidates are: int QComboBox::currentIndex() const
SamuelNLP
  • 4,038
  • 9
  • 59
  • 102

1 Answers1

1

I think you mean to use setCurrentIndex() rather than currentIndex() in your currentIndexPixel and currentIndexMM functions

Chris
  • 17,119
  • 5
  • 57
  • 60