Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor Joyce An's Avatar
    Join Date
    Dec 2008
    Posts
    86
    Hi all,
    there are many control in the widget. like the phone settings view. there are labels,radio buttons,line edit, time edit, list view and so on. I want to this widget can drag , it can move up and down.
    how to realize that? do you know some good suggestion?
    use
    Code:
    protected:
        void dragEnterEvent(QDragEnterEvent *event);
        void dropEvent(QDropEvent *event);
        void dragMoveEvent(QDragMoveEvent *event);
    or
        void mousePressEvent(QMouseEvent *evt);
        void mouseReleaseEvent(QMouseEvent *event);
        void mouseMoveEvent(QMouseEvent *event);
    ?
    thank you
    best wishes!
    Joyce
    where there is a will, there is a way.

  2. #2
    Regular Contributor Joyce An's Avatar
    Join Date
    Dec 2008
    Posts
    86
    rewrite
    void mousePressEvent(QMouseEvent *evt);
    void mouseReleaseEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    these method.
    who has mouse move example?
    where there is a will, there is a way.

  3. #3
    Regular Contributor Joyce An's Avatar
    Join Date
    Dec 2008
    Posts
    86
    void mouseMoveEvent(QMouseEvent *event);
    when call this method ? why my project doesn't call this method?
    where there is a will, there is a way.

  4. #4
    Nokia Developer Champion danhicksbyron's Avatar
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209
    Event routines are called by the Qt runtime, if you set them up correctly.

  5. #5
    Regular Contributor Joyce An's Avatar
    Join Date
    Dec 2008
    Posts
    86
    Do you help me look at my code?
    Code:
    void MSCSettingsWidget::mouseMoveEvent(QMouseEvent *evt)
    {
        if (!evt->modifiers().testFlag(Qt::ShiftModifier)) {
               QPoint pos = evt->pos();
               int distance = 0;
               scrollDirection = scrollMagnitude = 0;
               // determine the direction of automatic scrolling
               if (pos.x() < SCROLL_DISTANCE) {
                   scrollDirection = Left;
                   distance = pos.x();
                   this->move(distance,0);
               }
               else if (width() - pos.x() < SCROLL_DISTANCE) {
                   scrollDirection = Right;
                   distance = width() - pos.x();
                   this->move(distance,0);
               }
               if (pos.y() < SCROLL_DISTANCE) {
                   scrollDirection |= Up;
                   distance = pos.y();
                   this->move(0,distance);
               }
               else if (height() - pos.y() < SCROLL_DISTANCE) {
                   scrollDirection |= Down;
                   distance = height() - pos.y();
                   this->move(0,distance);
               }
               if (scrollDirection) {
                   scrollMagnitude = qRound((SCROLL_DISTANCE - distance) / 8);
               }
               rubberBand->setGeometry(QRect(origin, evt->pos()).normalized());
        }
    //    QGraphicsView::mouseMoveEvent( evt);
    }
    where there is a will, there is a way.

  6. #6
    Nokia Developer Champion danhicksbyron's Avatar
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209
    I've worked on similar algorithms. SCROLL_DISTANCE has to be fairly small (around 20) for this scheme to work on the phone, and then it gets pretty touchy.

    You're also missing a point of reference. You need to capture the "mouse down" position and delta off of that.

  7. #7
    Regular Contributor Joyce An's Avatar
    Join Date
    Dec 2008
    Posts
    86
    Code:
     mScene = new QGraphicsScene(this);
      mView = new QGraphicsView(mScene, this);
      mView->setAcceptDrops(true);
      mView->setDragMode(QGraphicsView::ScrollHandDrag);
    why it can't drag sensitive? some clicked controls can't drag move. do you use this method(mView->setDragMode(QGraphicsView::ScrollHandDrag)?
    where there is a will, there is a way.

Similar Threads

  1. Drag issue
    By chirpylife in forum Qt
    Replies: 2
    Last Post: 2010-03-26, 09:18
  2. How to scroll list view move per pixel?
    By Mozart2007 in forum Symbian C++
    Replies: 0
    Last Post: 2009-07-16, 07:41
  3. Pointer Move/Drag event in Javascript
    By sarikachahande in forum Symbian Web Runtime
    Replies: 2
    Last Post: 2009-04-04, 10:24
  4. Can we move text line on application view screen
    By ash_21 in forum Symbian C++
    Replies: 4
    Last Post: 2007-08-31, 07:32
  5. enabling move/drag events in Symbian 6.0 Crystal
    By cl_bonesbb in forum Symbian User Interface
    Replies: 1
    Last Post: 2001-12-05, 15:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved