Hello, I’m lost again! please help:
I’m trying to make a simple app in which a Spinner is the control to pan an image inside a QLabel.
I make the QLabel show the image by setting the pixmap. When user clicks the spinner, I make a copy of the original image but clipped on the XY coordinates indicated by the spinners, how ever I foudn no way of releasing the memory consumed by the copy of the image so a memory leak is at hand! Resistance is futile! :( LOL.
Any help would be really apreciated
PS (Total newbie!)
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QImage>
#include <QDebug>
#include <QMessageBox>
#include <QPixmap>
#include <QLibrary>
#include "scanner.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setWindowTitle(tr("OMR"));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_analizar_clicked()
{
image = new QImage("c:/omrtest.bmp");
if(image->isNull()) {
(new QMessageBox(QMessageBox::Critical,tr("Error"),tr("No se pudo cargar la imagen"),QMessageBox::Ok))->show();
}
//QImage *aux=new QImage(*image);
Scanner *scanner=new Scanner((new QImage(*image)));
}
void MainWindow::on_xPos_valueChanged(int posX)
{
QPixmap *aux=new QPixmap();
QImage img=image->copy(posX,2,100,100);
aux->convertFromImage(img);
ui->ojo->setPixmap(*aux);
ui->ojo->show();
}
↧