Results 1 to 10 of 10

Thread: QT 4.4 QGraphicsProxyWidget bridge Drag and Drop help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QT 4.4 QGraphicsProxyWidget bridge Drag and Drop help

    I can not forward Drag and Drop is here more flag to set?

    QGraphicsProxyWidget not forward events to subwidged


    Qt Code:
    1. #include <QGraphicsScene>
    2. #include <QtGui>
    3. #include <QGraphicsProxyWidget>
    4. #include <QGraphicsTextItem>
    5. /* qt4.4 !! */
    6.  
    7.  
    8. class Xedit : public QTextBrowser
    9. {
    10. Q_OBJECT
    11. //
    12. public:
    13. Xedit::Xedit( QWidget* parent = 0 )
    14. : QTextBrowser(parent)
    15. {
    16. setAcceptDrops(true);
    17. }
    18. void dragEnterEvent(QDragEnterEvent *event)
    19. {
    20. qDebug() << "### dragEnterEvent ";
    21. /////event->acceptProposedAction();
    22. insertFromMimeData(event->mimeData());
    23. }
    24. void insertFromMimeData ( const QMimeData * source )
    25. {
    26. /* external paste drag */
    27. qDebug() << "### insertFromMimeData ";
    28. if ( source->formats().contains("text/html") ) {
    29. QString draghtml = source->html();
    30. QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(draghtml);
    31. textCursor().insertFragment(fragment);
    32. return;
    33. }
    34. if ( source->hasText() ) {
    35. textCursor().insertText(source->text());
    36. return;
    37. }
    38. }
    39.  
    40. };
    41.  
    42. int main(int argc, char *argv[])
    43. {
    44. QApplication a(argc, argv);
    45.  
    46. a.setOrganizationName("Dummy");
    47. a.setOrganizationDomain("dummy.com");
    48. a.setApplicationName("TestEventforward");
    49. /////Xedit *extendededit = new Xedit;
    50. ///////extendededit->show();
    51. QGraphicsView view(&scene);
    52. view.show();
    53. QWidget *editor = new QWidget;
    54. QGridLayout *grid = new QGridLayout(editor);
    55. Xedit *extendededit = new Xedit;
    56. extendededit->setReadOnly(false);
    57. extendededit->setOpenExternalLinks(false);
    58. grid->addWidget(extendededit, 0, 0, 1, 1);
    59. QGraphicsProxyWidget *proxy = scene.addWidget(editor);
    60. /* http://doc.trolltech.com/main-snapshot/qgraphicsproxywidget.html */
    61. proxy->setAcceptDrops( true );
    62. ////proxy->setAttribute( Qt::WA_AcceptDrops , true );
    63. QGraphicsTextItem *text = scene.addText("Helo world..!");
    64. text->setZValue(1.2);
    65. extendededit->setDocument(text->document());
    66.  
    67. proxy->show();
    68. proxy->setZValue(1.5);
    69. a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
    70. return a.exec();
    71. }
    72.  
    73. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 
    Last edited by patrik08; 26th March 2008 at 09:11.

Similar Threads

  1. Drag & drop with model/view (Qt4)
    By yogeshm02 in forum Qt Programming
    Replies: 16
    Last Post: 19th September 2011, 20:36
  2. Problem with a cursor during Drag and Drop
    By mtrpoland in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2007, 15:46
  3. Replies: 7
    Last Post: 8th September 2006, 16:19
  4. Drag and drop outside the application
    By jpn in forum Newbie
    Replies: 7
    Last Post: 27th August 2006, 15:37
  5. Drag and drop revisited
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 30th June 2006, 16:41

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.