Unsolved Problem in Connecting ctkDoubleSpinBox
-
- do you mean this syntax?
Counter a, b; QObject::connect(&a, &Counter::valueChanged, &b, &Counter::setValue);
- I am getting a syntax error when I use this:
this->SliceController->&spinBox
-
@Meera-Hadid said in Problem in Connecting ctkDoubleSpinBox:
I am getting a syntax error when I use this:
this->SliceController->&spinBox
This is not legal C++. It should be:
&this->SliceController->spinBox
Whether you want the
&
depends on whetherspinbox
is already a pointer or not (I think yours is a pointer, in which case you would not want it?) -
@JonB said in Problem in Connecting ctkDoubleSpinBox:
&this->SliceController->spinBox
But according to the error message
cannot convert argument 1 from 'ctkDoubleSpinBox *' to 'const QObject *
It's already a pointer so the
&
is wrong.
I still think the header for this class is not included where the connect is done so the compiler doesn't know that ctkDoubleSpinBox is derived from QObject. -
- I did include
#include <ctkDoubleSpinBox.h>
- I did include
-
@Meera-Hadid Fix your connect as suggested by @JonB and try again
-
-
@Meera-Hadid said in Problem in Connecting ctkDoubleSpinBox:
Yes when I tried without using & it was raising an error that cannot convert from 'ctkDoubleSpinBox *' to 'const QObject *'
The issue is not getting pointer the issue is it cannot convert from 'ctkDoubleSpinBox *' to 'const QObject *'
Inserting a
&
randomly will not help. The message already tells that pointer-ness is not the issue. -
@Meera-Hadid said in Problem in Connecting ctkDoubleSpinBox:
The issue is not getting pointer the issue is it cannot convert from 'ctkDoubleSpinBox *' to 'const QObject *'
Do you mean you get same error message if you use new connect syntax?
-
@Meera-Hadid
Please do the following:- First, delete all the files from the build output directory. Do a fresh
qmake
followed by a build. Does the error still occur? - From the line number in the error message, are you quite sure it is on the
connect()
statement you have shown, and not some other? - I believe I already advised this before in answer to the same problem from you in another thread: on the line above the
connect()
put in
const QObject *temp = this->SliceController->spinBox;
Does that error (show message)?
- First, delete all the files from the build output directory. Do a fresh
-
const QObject *temp = this->SliceController->spinBox;
this works- But the signal
SIGNAL(valueChanged(double))
doesn't get activated (QLabel
value doesn't change). Is it becausetemp
is returingnullptr
?
-
Is it because temp is returing nullptr?
Pardon? Are you saying
this->SliceController->spinBox == nullptr
at the time you execute theconnect()
statement?Separately, put a
qDebug()
statement as the first thing in yourvoid qMRMLSliceWidget::updateLabel()
. -
@JonB said in Problem in Connecting ctkDoubleSpinBox:
Separately, put a qDebug() statement as the first thing in your void qMRMLSliceWidget::updateLabel().
Yes I did but that statement is not getting printed/executed
-
@Meera-Hadid
I have asked you other questions. If you don't want to respond to them that is up to you. -
- First, delete all the files from the build output directory. Do a fresh qmake followed by a build. Does the error still occur?
Since there are a lot of files it takes a lot of time to build hence I did not clear the build. - It's my bad that I assumed
this->SliceController->spinBox
was returning anullptr
. The problem was with slot I changed it. const QObject *temp = this->SliceController->spinBox;
worked for me
Thanks everyone for contributing.
- First, delete all the files from the build output directory. Do a fresh qmake followed by a build. Does the error still occur?