Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML drop and wheel events
Forum Updated to NodeBB v4.3 + New Features

QML drop and wheel events

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 7.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Schneidi
    wrote on last edited by
    #1

    Hi,

    I wonder how I get the drop event handling in a QDeclarativeView to work.

    I have a MainWindow with an QDeclarativeView and I set the MainWindow to acceptDrops this works fine.
    But now I can't convince my QDeclarativeView to accept drop events.

    @
    this->qml_view = new QDeclarativeView;
    this->qml_view->setAcceptDrops(true);
    @

    I thought that this could be the way to get this to work but I can't drop files in this view.
    Any ideas what I have to do, to get this to work ?

    By the way, are there any chances that I can implement mouse wheel events in an qml MouseArea ?

    Thanks for help guy ; )

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      [quote author="Schneidi" date="1284671038"]By the way, are there any chances that I can implement mouse wheel events in an qml MouseArea ?[/quote]

      This isn't really possible at the moment -- "QTBUG-7369":http://bugreports.qt.nokia.com/browse/QTBUG-7369 tracks this issue. If you need the functionality in the meantime, it should be possible to implement a custom QDeclarativeItem subclass to handle this.

      Regards,
      Michael

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Schneidi
        wrote on last edited by
        #3

        Ok the wheel event isn't a real problem, I implemented it in the mainWindow and synch it with the qml environment.

        But a problem is still the fact that I can't drop files to the mainWindow because I have the
        QDeclaritiveView as centralWidget in my main window.

        How do I drop files into the QDeclarativeView ?

        @

        MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
        {
        ui->setupUi(this);

        this->v = new QDeclarativeView;
        this->setCentralWidget(v);
        this->v->setSource(QUrl("qrc:/qml_source/test2.qml"));
        this->v->setResizeMode(QDeclarativeView::SizeRootObjectToView);
        this->v->setAcceptDrops(true);
        this->setAcceptDrops(true);
        

        }
        @

        Once I set the QDeclarativeView as central object, I loose the ability to drop files into mainWindow.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cbrake
          wrote on last edited by
          #4

          A mouse up/down can be used in the following code to increment/dec the text value when the cursor is over top the item. What is the best way to make the scroll wheel do the same? Note, I need this for many items on a single screen. With a QDeclarativeItem subclass, would I need to implement the below in C++?

          With the "implement in mainWindow and sync with qml", would this approach work and how does it look from a high level?

          I'm still climbing the QML learning curve, so so looking for a high level overview or a place to start.

          Thanks,
          Cliff

          @
          Rectangle {
          id: valuebox
          smooth: true
          anchors.margins: 10
          radius: 10
          property color default_color: "white"
          color: default_color
          property alias text: text.text
          property alias text_color: text.color
          property int default_pixel_size

          Text {
              id: text
              anchors.centerIn: parent; anchors.verticalCenterOffset: -1
              font.pixelSize: parent.width > parent.height ? parent.height * .5 : parent.width * .5
              color: "white"
              style: Text.Sunken
              styleColor: "black"
              smooth: true
          }
          
          Keys.onUpPressed: {
              text.text = text.text - (-1)
          }
          
          Keys.onDownPressed: {
              text.text = text.text - 1
          }
          
          MouseArea {
              anchors.fill: parent
              hoverEnabled: true
          
              onEntered: {
                  default_pixel_size = text.font.pixelSize
                  text.font.pixelSize = default_pixel_size + 5
                  parent.color = "yellow"
                  valuebox.focus = true
              }
          
              onExited: {
                  text.font.pixelSize = default_pixel_size
                  parent.color = default_color
                  valuebox.focus = false
              }
          }
          

          }

          @

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved