News: I solved my own problem. Here is the code:
{
if ((event
->type
() == QMouseEvent::MouseButtonDblClick) && (event
->button
() == Qt
::LeftButton)) {
timer.stop();
QLabel *child
= static_cast<QLabel
*>
(childAt
(event
->pos
()));
if( const QPixmap * p
= child
->pixmap
() ) {
connect(&dialog,SIGNAL(destroyed()),this,SLOT(restartTimer()));
label->setPixmap(a);
dialog.resize(a.size());
dialog.exec();
}
}
}
{
imagemsemred = image;
nova_imagem = image;
if (image.height() > ui->Image->height())
nova_imagem = image.scaledToHeight(ui->Image->height());
if (image.width() > ui->Image->width())
nova_imagem = image.scaledToWidth(ui->Image->width());
return nova_imagem;
}
void MainWindow::mousePressEvent(QMouseEvent *event)
{
if ((event->type() == QMouseEvent::MouseButtonDblClick) && (event->button() == Qt::LeftButton))
{
timer.stop();
QLabel *child = static_cast<QLabel*>(childAt(event->pos()));
if( const QPixmap * p = child->pixmap() )
{
QDialog dialog;
connect(&dialog,SIGNAL(destroyed()),this,SLOT(restartTimer()));
QLabel * label = new QLabel(&dialog);
QPixmap a = QPixmap::fromImage(imagemsemred);
label->setPixmap(a);
dialog.resize(a.size());
dialog.exec();
}
}
}
QImage MainWindow::newDimension(QImage image)
{
imagemsemred = image;
nova_imagem = image;
if (image.height() > ui->Image->height())
nova_imagem = image.scaledToHeight(ui->Image->height());
if (image.width() > ui->Image->width())
nova_imagem = image.scaledToWidth(ui->Image->width());
return nova_imagem;
}
To copy to clipboard, switch view to plain text mode
The only problem is that I don't know what to do with that "p", since I don't use it as a variable but Its necessary for the software only allows mouse events over the Label.
Thanks for everything,
Momergil
Bookmarks