This is the MainWindow class header.
Well, I can agree that this could be a part of MainWindow class header 
There should be nothing wrong in your code, my quick test looks very similar and works:
// test.h
#include <QtGui>
Q_OBJECT
public:
explicit MainW
( QWidget * parent
= NULL );
public slots:
void warning( int value ){
this
->setWindowTitle
(QString::number(value
));
}
};
// test.cpp
#include "test.h"
scene->setSceneRect(0,0,1000,1000);
view->setScene(scene);
this->setCentralWidget(view);
connect( view->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(warning(int)) );
}
int main(int argc, char *argv[]){
MainW m;
m.show();
return a.exec();
}
// test.h
#include <QtGui>
class MainW : public QMainWindow{
Q_OBJECT
QGraphicsView * view;
public:
explicit MainW( QWidget * parent = NULL );
public slots:
void warning( int value ){
this->setWindowTitle(QString::number(value));
}
};
// test.cpp
#include "test.h"
MainW::MainW( QWidget * parent ) : QMainWindow(parent){
view = new QGraphicsView(this);
QGraphicsScene * scene = new QGraphicsScene(this);
scene->setSceneRect(0,0,1000,1000);
view->setScene(scene);
this->setCentralWidget(view);
connect( view->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(warning(int)) );
}
int main(int argc, char *argv[]){
QApplication a(argc, argv);
MainW m;
m.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Try to make a clean build ( make clean, qmake, make ). If this doesn't help, post full code (if you can).
Bookmarks