PDA

View Full Version : Am I not understanding QPixmaps? SOLVED!



bjh
18th September 2008, 18:34
Hi All,

Using MSVS C++ 2008 Express, with Qt 4.4.1, I'm trying to use a QPixmap (in a QGraphicsScene with a QGraphicsView) to represent a dynamic map. It has a colored background (via fill()), and I draw lines on it (via painter's drawPolylines()). First time my method to draw the map is called, it works fine. Subsequent calls to it appear to do nothing, as the displayed QPixmap lines do not change. I even tried removing the code after the fill() just to see the fill() happen - it didn't! Am I not supposed to be using a QPixmap this way? Code snippet below; am I missing something obvious? THANKS!

bjh


void Window::drawMap()
{
// draw the pixmap of the map!
gui_pixmap->fill("blanchedalmond");
for (int i=0; i<iDBLinkCount; i++)
{
drawOnePolyline(i, DBLinkRank[i]);
}
drawTextNames(100);
//scene->update();
}

Problem solved. I was using the QPixmap as a BackgroundBrush, and neglected to add these two statements to where the map gets redrawn:


backBrush->setTexture(*gui_pixmap);
view->setBackgroundBrush(*backBrush);


Sorry to have posted without looking at my code more thoroughly!