I have encountered a strange compiler error when trying to connect a QGraphicsView's QScrollBar to a slot in my own class.
The code is as follows (simplified):

Qt Code:
  1. MyClass::MyClass(QWidget * parent, Qt::WindowFlags f): QDialog(parent, f)
  2. {
  3. _widget.setupUi(this);
  4.  
  5. _imageScene = new QGraphicsScene;
  6.  
  7. _widget.graphicsView->setScene(_imageScene);
  8.  
  9. //This works
  10. connect(_widget.imageListView->selectionModel(), SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(currentImageChanged(const QModelIndex&)));
  11.  
  12. //These two are causing the compiler errors
  13. connect(_widget.graphicsView->horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(updateVisibleRect()));
  14. connect(_widget.graphicsView->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(updateVisibleRect()));
  15. }
To copy to clipboard, switch view to plain text mode 

I didn't forget the Q_OBJECT declaration and the updateVisibleRect() is declared as a slot just like the other slots I have in the class.
There are a couple of other connects in the constructor I omitted. But they are working just fine. Only if I try to connect the QGraphicsView's scroll bars to my slots, there is a compiler error:

Qt Code:
  1. src/MyClass.cpp:58: error: no matching function for call to `MyClass::connect(QScrollBar*, const char*, MyClass* const, const char*)'
  2.  
  3. d:/Programme/Qt/2009.04/qt/include/QtCore/../../src/corelib/kernel/qobject.h:202: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
  4.  
  5. d:/Programme/Qt/2009.04/qt/include/QtCore/../../src/corelib/kernel/qobject.h:308: note: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
  6.  
  7. src/MyClass.cpp:59: error: no matching function for call to `MyClass::connect(QScrollBar*, const char*, FATThresholdDialog* const, const char*)'
  8.  
  9. d:/Programme/Qt/2009.04/qt/include/QtCore/../../src/corelib/kernel/qobject.h:202: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
  10.  
  11. d:/Programme/Qt/2009.04/qt/include/QtCore/../../src/corelib/kernel/qobject.h:308: note: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const
To copy to clipboard, switch view to plain text mode 

It seems to me that there is a problem with the type returned by QGraphicsView::horizontalScrollBar().
Strangely, connecting the selectionModel of a QListView I'm also using to one of my slots works just fine.

Is there something I am missing? Any ideas on what causes the error?

Thanks in advance

Someone With A Question