hi thanks for the reply. i looked at the doc and the scribble example but im still having trouble implementing it into my program. would anyone be able to help me or provide a simple example?
here's a snippet from the scribble example:
{
if (width() > image.width() || height() > image.height()) {
int newWidth = qMax(width() + 128, image.width());
int newHeight = qMax(height() + 128, image.height());
resizeImage
(&image,
QSize(newWidth, newHeight
));
update();
}
}
void ScribbleArea::resizeEvent(QResizeEvent *event)
{
if (width() > image.width() || height() > image.height()) {
int newWidth = qMax(width() + 128, image.width());
int newHeight = qMax(height() + 128, image.height());
resizeImage(&image, QSize(newWidth, newHeight));
update();
}
QWidget::resizeEvent(event);
}
To copy to clipboard, switch view to plain text mode
and:
void ScribbleArea
::resizeImage(QImage *image,
const QSize &newSize
) {
if (image->size() == newSize)
return;
newImage.fill(qRgb(255, 255, 255));
painter.
drawImage(QPoint(0,
0),
*image
);
*image = newImage;
}
void ScribbleArea::resizeImage(QImage *image, const QSize &newSize)
{
if (image->size() == newSize)
return;
QImage newImage(newSize, QImage::Format_RGB32);
newImage.fill(qRgb(255, 255, 255));
QPainter painter(&newImage);
painter.drawImage(QPoint(0, 0), *image);
*image = newImage;
}
To copy to clipboard, switch view to plain text mode
but i'm not sure how this applies in my case. im trying to scale the graphicsview and button in my widget with changes to the main window. any help please? this is what i tried to do??? what functions do i need to access to make the size changes to the graphicsview?
{
//scene.setSceneRect(0, 0, width()-4, height()-4);
graphicsView->resize(width(),height());
}
void scalingApp::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
//scene.setSceneRect(0, 0, width()-4, height()-4);
graphicsView->resize(width(),height());
}
To copy to clipboard, switch view to plain text mode
Bookmarks