Results 1 to 2 of 2

Thread: Detect mouseReleaseEvent on QImage insert in QTextedit

  1. #1
    Join Date
    Apr 2012
    Posts
    40
    Platforms
    Unix/X11 Windows

    Default Detect mouseReleaseEvent on QImage insert in QTextedit

    Hi i want detect when i click on Qimage inserted to QTextEdit . i make Filee class but dont work.
    Qt Code:
    1. // .H
    2. #ifndef FILEE_H
    3. #define FILEE_H
    4.  
    5. #include <QWidget>
    6. #include <QMessageBox>
    7. #include <QEvent>
    8.  
    9. class Filee : public QWidget, public QImage
    10. {
    11. Q_OBJECT
    12.  
    13. public:
    14. Filee();
    15.  
    16. signals:
    17.  
    18. public slots:
    19. void lol();
    20.  
    21. protected :
    22. bool event(QEvent *);
    23.  
    24. };
    25.  
    26. #endif // FILEE_H
    27.  
    28.  
    29.  
    30.  
    31. //.CPP
    32. #include "filee.h"
    33.  
    34. Filee::Filee()
    35. : QImage(":/File.png")
    36. {
    37. }
    38.  
    39. bool Filee::event(QEvent * e)
    40. {
    41. QMessageBox::information(0, QString::number(e->type()) , "sdf");
    42. return true;
    43. }
    44.  
    45.  
    46.  
    47. //Add Filee to textedit
    48. Filee f1;
    49. ui->textEdit->textCursor().insertImage( (QImage) f1, "f1");
    To copy to clipboard, switch view to plain text mode 

    After click on this image in textedit do nothing , event are not detected ;(

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Detect mouseReleaseEvent on QImage insert in QTextedit

    You are inserting a QImage, and QImage does not receive mouse event, only QWidgets receive mouse events

Similar Threads

  1. QTextEdit insert and get html
    By Qtonimo in forum Qt Programming
    Replies: 1
    Last Post: 31st October 2012, 03:10
  2. How to detect scroll on QtextEdit
    By tonnot in forum Newbie
    Replies: 1
    Last Post: 10th October 2011, 21:15
  3. QTextEdit insert html
    By abrahametalero in forum Newbie
    Replies: 4
    Last Post: 12th February 2011, 18:58
  4. Replies: 6
    Last Post: 17th January 2008, 23:46
  5. Replies: 7
    Last Post: 12th August 2006, 15:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.