For some bizarre reason, setting the scene's rect myself (which should save Qt from
computing bounding rects) causes huge mem consumption and slows down everything.
I have no idea why that would be.
_lines.append(line);
addItem(line);
}
+ emit heightChanged(height());
}
ChatScene::~ChatScene() {
for(int i = end+1; i < _lines.count(); i++) {
_lines.value(i)->moveBy(0, h);
}
- //setSceneRect(0, 0, _width, _height);
+ emit heightChanged(height());
}
}
line->setPos(0, _height);
_height += line->setColumnWidths(_timestampWidth, _senderWidth, w - _timestampWidth - _senderWidth);
}
- qDebug() << "setting width";
- setSceneRect(0, 0, _width, _height * 2);
+ emit heightChanged(_height);
}
void ChatScene::mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent ) {
public slots:
void setWidth(int);
+ signals:
+ void heightChanged(int height);
+
protected slots:
void rowsInserted(const QModelIndex &, int, int);
void mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent );
|QGraphicsView::DontSavePainterState
|QGraphicsView::DontAdjustForAntialiasing);
_scene = new ChatScene(Client::messageModel(), this);
- _scene->setWidth(width());
+ connect(_scene, SIGNAL(heightChanged(int)), this, SLOT(sceneHeightChanged(int)));
+ //_scene->setWidth(width());
setScene(_scene);
-
+ setSceneRect(0, 0, width(), 0);
}
qDebug() << "resize";
}
+void ChatView::sceneHeightChanged(int h) {
+ setSceneRect(0, 0, width(), h);
+}
+
void ChatView::clear()
{
}
protected:
virtual void resizeEvent(QResizeEvent *event);
+ protected slots:
+ virtual void sceneHeightChanged(int height);
+
private:
ChatScene *_scene;
};