PDA

View Full Version : 2D Game



Peppy
30th April 2011, 23:10
I am going to program easy game in Qt, which 2D widgets I should use to display game? I've tried GraphicsView, but that's really awful for me....unexpected behavior around painting onto the screen such as added scrollbars in my main window to see full GraphicsView ?! But the size is the same as main window! It's too strange.

Added after 40 minutes:

I am quiet angry myself, it's terrible to work with GraphicsView and other GraphicsXYZ classes, awful! I don't understand how it can works!

Added after 1 8 minutes:

I have a lot of questions:
1. I have an inherited class QGraphicsView and implemented paintEvent, why does debugger write: QPainter::begin: Paint device returned engine == 0, type: 1 ??
This is whole code:


void GraphicsView::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setBrush(QBrush(QColor(255,127,0)));
painter.drawRect(this->sceneRect());
}

And I am not drawing outside from paintEvent method.
2. Why I have scollbars in my GraphicsView window ? How to remove them?

It's amazingly silly...

franz
1st May 2011, 12:45
Do your painting in graphics scene and graphics items. Leave QGraphicsView as it is. It is specifically designed to be painted on by qgraphicsscene. Read more on Graphics/View (http://doc.trolltech.com/latest/graphicsview.html).