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. keyPressEvent in QQuickPaintedItem has stopped working after moving file to StackView
Forum Updated to NodeBB v4.3 + New Features

keyPressEvent in QQuickPaintedItem has stopped working after moving file to StackView

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 181 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.
  • D Offline
    D Offline
    damian28102000
    wrote on last edited by
    #1

    Hi

    I have a problem with class inherited from class QQuickPaintedItem, after moving file to stackview it has stopped working

    void CoreNode::keyPressEvent(QKeyEvent* pEvent)
    {
        if (mpCurrentNumberBox != nullptr)
        {
            mpCurrentNumberBox->keyPress(pEvent);
            update();
    

    but

    void CoreNode::mousePressEvent(QMouseEvent* pEvent)
    {
        setFocus(true);
        mLastMousePosition = pEvent->pos();
        if (isMouseOnHeader(pEvent->pos()))
        {
            mIsMouseClickedOnHeader = true;
    

    mousePressEvent still works

    main.qml

    Window {
        id: window
        visible: true
        width: 1280
        height: 720
        title: "Block-Based Programming Language"
    
        Cursor {
            id: curs
        }
    
        StackView {
            id: stackView
            anchors.fill: parent
            initialItem: "Tasks.qml"
        }
    
        Component.onCompleted: {
            JS.dbInit()
        }
    
    1 Reply Last reply
    0
    • jeremy_kJ Online
      jeremy_kJ Online
      jeremy_k
      wrote on last edited by
      #2

      StackView is a focusc scope. The view must have focus == true for the current item to have active focus.

      Asking a question about code? http://eel.is/iso-c++/testcase/

      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