Hello!

I never used QMouseEvent before and now I'm trying to learn how to do it, but till now I'm unable to be sucessfull. What I want to do is:

I'm showing a movie (or else only one image) that consists in a series of images inside a QLabel that change over time due to a QTimer clock. Since the images shown are offently resized to fit in the QLabel's size, I want to add the possibility for the user to left double click in the image (or else in the QLabel, ether works) and a QDialog should appear, showing the imagem inside, while the movie should stop. When the QDialog is destroyed, the movie should continue.

Till now what I did was essentially to copy from an example and the code almost worked. Here it is:

Qt Code:
  1. void MainWindow::mousePressEvent(QMouseEvent *event)
  2. {
  3. QLabel *child = static_cast<QLabel*>(childAt(event->pos()));
  4. if (!child)
  5. qDebug() << "Problem!!!!!";
  6. else if (event->button() == Qt::LeftButton)
  7. {
  8. timer.stop();
  9. QDialog qd;
  10. connect(&qd,SIGNAL(destroyed()),this,SLOT(restartTimer()));
  11. child->setParent(&qd);
  12. qd.exec();
  13. }
  14. }
  15.  
  16. void MainWindow::restartTimer()
  17. {
  18. timer.start(1000);
  19. }
To copy to clipboard, switch view to plain text mode 

The problem with this code is that the childAt() and setParent() functions seems not to "copy" the image inside the QLabel, but to TAKE it away - so while displaying the QDialog the QLabel in which was the image turns empty. As if that wasn't enough, when the timer restarts and its time for the new image to be shown, the software crash, since the QLabel in which the new image was supposed to appear was cut from its original place and put in the QDialog.

No to mension that I wasn't able to understand how can I identify if the press event is a DoubleClick and at the same type if it is with the Left Button.


So could somebody give me a typ, please?

Thanks!


Momergil