Set mouse focus/pointer to popup QListView

  • My application displays QListView (myListView) as pop-up in mainwindow in response to mouse move event.

    I need to set mouse pointer/focus to the pop up ListView.
    @myListView.setFocus(Qt::OtherFocusReason);@ is not working.

    Any idea or suggestion for doing this

  • Lifetime Qt Champion


    What exactly does not work ?

  • Thanks for your answer.

    I have subclasses QWidget(myWidget), and QListView(myListView). myWidget contains myListView. myListView is displayed as popup on mouse hovering over mywidget. I want to shift mouse pointer focus from myWidget to myListView. Mouse pointer does not focus to the popup Listview and still foucses on the mainwindow area, having myWidget.

  • Lifetime Qt Champion

    So each time you hover over any place of your widget, the QListView appears where the pointer is and follows it ?

  • Thanks for your reply.

    Not at every point of my widget. I have drawn QRects on the Widget. When mouse hovers over one of these QRects, then the ListView appears in popup and it is hidden when mouse moves away from that position of the widget.

    Why do I need to set mouse focus to ListView from my Widget?---->My QListView is displaying a number of QPixMaps. These pixmaps are clickable; enlarged version of the pixmap will be displayed in other part of the QMainWindow.

    I want to set my mouse focuse on the ListView so that I can catch click or mouse move action from ListView.

  • Lifetime Qt Champion

    Technically, your ListView will get the focus once you click on it. Did you try with Qt::MouseFocusAction ?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.