Hi,
I have the following code:
void xpPageWidget
::setPage(QPicture* image
) {
m_Pixmap.fill(Qt::white);
qDebug
(ds_filepos
+QString("MPageDisplay::setPage(): image =%1x%2").
arg(image
->width
()).
arg(image
->height
()));
qDebug
(ds_filepos
+QString("MPageDisplay::setPage(): m_Pixmap=%1x%2").
arg(m_Pixmap.
width()).
arg(m_Pixmap.
height()));
qDebug
(ds_filepos
+QString("MPageDisplay::setPage(): this =%1x%2").
arg(width
()).
arg(height
()));
image->play(&painter);
//painter.drawPicture(0,0,*image);
}
void xpPageWidget::setPage(QPicture* image)
{
m_Pixmap.fill(Qt::white);
QPainter painter(&m_Pixmap);
qDebug(ds_filepos+QString("MPageDisplay::setPage(): image =%1x%2").arg(image->width()).arg(image->height()));
qDebug(ds_filepos+QString("MPageDisplay::setPage(): m_Pixmap=%1x%2").arg(m_Pixmap.width()).arg(m_Pixmap.height()));
qDebug(ds_filepos+QString("MPageDisplay::setPage(): this =%1x%2").arg(width()).arg(height()));
image->play(&painter);
//painter.drawPicture(0,0,*image);
}
To copy to clipboard, switch view to plain text mode
And the output:
.\gui\xpPageWidget.cpp(29): MPageDisplay::setPage(): image =732x327
.\gui\xpPageWidget.cpp(30): MPageDisplay::setPage(): m_Pixmap=794x1123
.\gui\xpPageWidget.cpp(31): MPageDisplay::setPage(): this =796x1125
.\gui\xpPageWidget.cpp(29): MPageDisplay::setPage(): image =732x327
.\gui\xpPageWidget.cpp(30): MPageDisplay::setPage(): m_Pixmap=794x1123
.\gui\xpPageWidget.cpp(31): MPageDisplay::setPage(): this =796x1125
To copy to clipboard, switch view to plain text mode
image get's painted to by code like this:
{
if(!p) return;
QPen aPen
= m_BorderColor;
...
p->setPen(aPen);
p->drawLine(aRect.topLeft(),aRect.topRight());
...
}
{
drawFrame(p);
if(m_ReportEngine->m_ShowNames)
{
p->setPen(Qt::lightGray);
p->setFont(getFont());
p
->drawText
(*m_Rect,Qt
::AlignCenter,
QString("%1:%2").
arg(className
()).
arg(name
()));
}
return true;
}
void ReportBase::drawFrame(QPainter *p,QRectF aRect)
{
if(!p) return;
QPen aPen = m_BorderColor;
...
p->setPen(aPen);
p->drawLine(aRect.topLeft(),aRect.topRight());
...
}
bool ReportBase::draw(QPainter *p)
{
drawFrame(p);
if(m_ReportEngine->m_ShowNames)
{
p->setPen(Qt::lightGray);
p->setFont(getFont());
p->drawText(*m_Rect,Qt::AlignCenter,QString("%1:%2").arg(className()).arg(name()));
}
return true;
}
To copy to clipboard, switch view to plain text mode
The painting worked fine in Qt3 (1st Block line 11: image->play(&painter) ) but in Qt4 the QPicture painting is too big and goes off my pageWidget. The only way to get it within the required 796x1125 (A4 Paper) area on pageWidget (see output) is to scale it ... I still have to work out the correct ratios for QPainter::scale ( qreal sx, qreal sy ) to make it fit snuggly but that seems like something that should work without scaling.
Thus, is there some scaling/transformations when the paint commands are played back to a QPainter? What's the pixel size of an A4 Paper... would that be a potential issue?
Bookmarks