Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cant Get Touch Inputs ın QPixMap(image) in QGraphicsView
Qt 6.11 is out! See what's new in the release blog

Cant Get Touch Inputs ın QPixMap(image) in QGraphicsView

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.7k 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.
  • Y Offline
    Y Offline
    Yusuf
    wrote on last edited by
    #1

    I have a QScene object in QWidget and inside QWidget i have QGraphicsView. I convert images to QPixMap give it to QScene as an element and i defined touch events in QGraphicsView class. In QGraphicsView's creator method i enabled touch events with:

    @
    viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
    @

    and i am managing touch event by overriding ViewPortEvent method:

    @
    bool DicomView::viewportEvent(QEvent *event)

    {

    if(event->type() == QEvent::TouchBegin)
    
    {
    
        QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
    
    
              .......
    

    return QGraphicsView::viewportEvent(event);

    }
    @

    PS:DicomView is type of QGraphicsView.

    My problem is when i run the application i can get the touch inputs from the view but when get to QView can not get touch inputs from QPixMap. I tried putting the methods inside QScene instead of QGraphicsView but QScene does not have a ViewPortEvent method. What am i supposed to do? I appreciate for the answers, thank you.

    [EDIT: code formatting, please wrap in @-tags, Volker]

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      I try to read between the lines: are you trying to get those events in your QGraphicsItems or in your QGraphicsScene? If so, you need to use QGraphicsItem::setAcceptTouchEvents on your items, then you get the QTouchEvents in your QGraphicsItem::sceneEvent() override (or QGraphicsScene::event).

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      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