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. Qt::CursorShape + QML

Qt::CursorShape + QML

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 2 Posters 7.6k Views
  • 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.
  • B Offline
    B Offline
    bunjee
    wrote on last edited by
    #1

    Greetings Trolls,

    I would like to use the Qt enum CursorShape in my QML. Like this:
    @Component.onCompleted: {
    wView.setItemCursor(buttonMenuMouse, Qt.PointingHandCursor);
    }@

    Unfortunately when trying to I get the following error:

    bq. Error: Unknown method parameter type: Qt::CursorShape

    Is there a way to register Qt::CursorShape in my QML context or do I have to reimplement my own enum ?

    Thanks.

    B.A.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kxyu
      wrote on last edited by
      #2

      and what exactly is a wView object? if you register it manually you could implement a member function not using Qt::CursorShape type

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bunjee
        wrote on last edited by
        #3

        bq. if you register it manually you could implement a member function not using Qt::CursorShape type

        Yes I could, but I would like to use Qt::CursorShape :).

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bunjee
          wrote on last edited by
          #4

          Did this workaround:

          @Component.onCompleted: {
          wView.setItemCursor(boxMouseArea, "PointingHandCursor");
          }@

          And in the C++:

          @void WControllerView::setItemCursor(QGraphicsObject * object, const QString & shape)
          {
          Q_ASSERT(object);

          Qt::CursorShape cursor;
          
          if (shape == "PointingHandCursor") cursor = Qt::PointingHandCursor;
          else                               cursor = Qt::ArrowCursor;
          
          object->setCursor(QCursor(cursor));
          

          }@

          1 Reply Last reply
          0
          • K Offline
            K Offline
            Kxyu
            wrote on last edited by
            #5

            that's exactly what I meant)

            1 Reply Last reply
            0
            • B Offline
              B Offline
              bunjee
              wrote on last edited by
              #6

              Not very sexy but it works :).

              Looks like the javascript is not a big fan of enums.

              1 Reply Last reply
              0
              • K Offline
                K Offline
                Kxyu
                wrote on last edited by
                #7

                well that's no to so bad. you just need to register the type like other enums in QML are registered
                i've searched for it in declarative sources, and what i found is that you should use Q_ENUMS macro for registering enum type

                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