×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    63

    How to drag on QGraphicsView frame

    I wrote a picture browser.use QGraphicsScene,QGraphicsView,QGraphicsPixItem, display some small pictures on screen. How to drag QGraphicsView class to look other picture.....

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to drag on QGraphicsView frame

    Qt 4.6 has gesture framework you may be interested in (if I understood the question correctly)
    http://doc.trolltech.com/4.6/gestures-overview.html
    There is also example, you may try
    http://doc.trolltech.com/4.6/gesture...egestures.html

  3. #3
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    63

    Re: How to drag on QGraphicsView frame

    hi divanov,
    My project is in the Qt for symbian platform, it is similar to the image viewer, displayed a lot of small pictures on the screen,
    but the screen only shows the part pictures, I would like to view other pictures using drag and drop way.
    I know that these three functions is to realize drag and drop, but I don't konw how to write code........
    Thanks..........

  4. #4
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    63

    Re: How to drag on QGraphicsView frame

    three funtions :mousePressEvent(),dropEvent(),dragEnterEvent()

  5. #5

  6. #6
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    63

    Question Re: How to drag on QGraphicsView frame

    thanks, these examples I have read. These examples is achieve to single item drag and drop .But I need to drag and drop whole QGraphicsView.
    Because all pictures display on QGraphicsView.

  7. #7
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to drag on QGraphicsView frame

    Quote Originally Posted by wudelei View Post
    thanks, these examples I have read. These examples is achieve to single item drag and drop .But I need to drag and drop whole QGraphicsView.
    Because all pictures display on QGraphicsView.
    But QGraphicsView is a single item derived from QWidget.

  8. #8
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    63

    Unhappy Re: How to drag on QGraphicsView frame

    yes, I understand your means, but I really don't know how to wrote the code about drag and drop.
    this is I write the code, but can't realize funtion.
    void ImageGraphicsView::dragEnterEvent(QDragEnterEvent *event)
    {
    if(event->mimeData()->hasFormat("application/x-dndImage"))
    {
    event->accept();
    }
    else
    {
    event->ignore();
    }
    }

    void ImageGraphicsView::dropEvent(QDropEvent *event)
    {
    if(event->mimeData()->hasFormat("application/x-dndImage"))
    {
    QByteArray itemData = event->mimeData()->data("application/x-dndImage");
    QDataStream dataStream(&itemData,QIODevice::ReadOnly);

    QPoint currentpos;
    dataStream >> currentpos;

    event->setDropAction(Qt::MoveAction);
    event->accept();
    }
    else
    {

    }
    }

    void ImageGraphicsView::mousePressEvent(QMouseEvent* event)
    {
    QGraphicsItem* item = itemAt(event->posF().toPoint());

    QPoint eventpoint = event->pos();
    QRect square(eventpoint.x(),eventpoint.y(),240,240);

    update(square);
    QByteArray itemData;
    QDataStream dataStream(&itemData,QIODevice::WriteOnly);
    dataStream << this << eventpoint;

    QMimeData* data = new QMimeData;
    data->setData("application/x-dndImage",itemData);

    QDrag* drag = new QDrag(this);
    drag->setMimeData(data);
    drag->setParent(this);
    drag->start();

    }

Similar Threads

  1. ALERT: Invalid heap pointer found
    By polys in forum Mobile Java General
    Replies: 2
    Last Post: 2009-08-02, 12:25
  2. Cannot run streaming through a J2ME code on WTK2.5.2.
    By itismohit in forum Streaming and Video
    Replies: 0
    Last Post: 2009-03-30, 07:49
  3. FATAL ERROR - Applet 17 with certain png's
    By OneNineStudios in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2008-12-17, 13:11
  4. Please HELP, very strange...
    By gg17 in forum Mobile Java General
    Replies: 1
    Last Post: 2005-07-21, 10:43
  5. 编译通过运行出错,请高手指教!
    By hdmxch in forum [Archived] Other Programming Discussion 关于其他编程技术的讨论
    Replies: 9
    Last Post: 2004-08-08, 14:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×