Tepi
28th August 2009, 13:27
Hi there,
I have some strange problem with the qobject_cast. I was successfully using the same code at the another class and after I moved the code to the new class it won't work anymore. If I build the project with the debug configuration and run it at the debug mode I can't even debug it normally because debugger stops automatically at the qmetaobject.cpp files "QObject *QMetaObject::cast(QObject *obj) const" function. And this happens even though I haven't set the breakpoint in it... And it won't continue debugging through there even I press "Continue".
Here's the code where I use qobject_cast... the problem goes away if I comment out these lines. So the problem should be related to this, I assume ;)
Note that at the code the "component" is type QWidget *component
void GUIComponent::setComponentOptions(const QString componentOptions)
{
options = componentOptions;
if(QSlider *slider = qobject_cast<QSlider *>(component))
{
if(options == "horizontal")
slider->setOrientation(Qt::Horizontal);
}
else if(QPushButton *button = qobject_cast<QPushButton *>(component))
{
button->setText(options);
}
}
Probably it is just some stupid mistake like usually ;)
Any help would be greatly appreciated.
I have some strange problem with the qobject_cast. I was successfully using the same code at the another class and after I moved the code to the new class it won't work anymore. If I build the project with the debug configuration and run it at the debug mode I can't even debug it normally because debugger stops automatically at the qmetaobject.cpp files "QObject *QMetaObject::cast(QObject *obj) const" function. And this happens even though I haven't set the breakpoint in it... And it won't continue debugging through there even I press "Continue".
Here's the code where I use qobject_cast... the problem goes away if I comment out these lines. So the problem should be related to this, I assume ;)
Note that at the code the "component" is type QWidget *component
void GUIComponent::setComponentOptions(const QString componentOptions)
{
options = componentOptions;
if(QSlider *slider = qobject_cast<QSlider *>(component))
{
if(options == "horizontal")
slider->setOrientation(Qt::Horizontal);
}
else if(QPushButton *button = qobject_cast<QPushButton *>(component))
{
button->setText(options);
}
}
Probably it is just some stupid mistake like usually ;)
Any help would be greatly appreciated.