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
Qt Code:
  1. void GUIComponent::setComponentOptions(const QString componentOptions)
  2. {
  3. options = componentOptions;
  4.  
  5. if(QSlider *slider = qobject_cast<QSlider *>(component))
  6. {
  7. if(options == "horizontal")
  8. slider->setOrientation(Qt::Horizontal);
  9. }
  10. else if(QPushButton *button = qobject_cast<QPushButton *>(component))
  11. {
  12. button->setText(options);
  13. }
  14. }
To copy to clipboard, switch view to plain text mode 

Probably it is just some stupid mistake like usually

Any help would be greatly appreciated.