Mouse selection handler ?



  • Is there a way to get the coordinates of a mouse selection ?

    I want to create something like a selecting in desktop/files , when you go to your desktop and click left button and drag it you can see a blue selecting " in windows at least " that you can select things using it..

    I want something like that , when the user clicks a button the mouse acts like it acts in files and select things and then return the coordinates or a graph view.

    Basically you know the tool called snipping tool in windows ? you know when you click the button it renders a thing that lets you select what you want ? that's what I want.

    can you direct me to a class or something that gives function that does the same job ?

    I used this:

    @

    QGraphicsView Graph(this);

    Graph.setInteractive(true);
    Graph.setDragMode(Graph.RubberBandDrag);

    @

    but it doesn't show the rubber or whatever it's called ,



  • I followed this:

    http://qt-project.org/doc/qt-4.8/qrubberband.html

    and it's working great except I want it to get the coordinates outside of my program not just inside it.



  • I don't think you can control mouse events if they are outside of your application.
    If you need to grab a region of a screen then open a transparent borderless widget on a whole screen to pickup mouse events on the desktop.



  • Thanks for answering , I didn't put the parent in the QtRubberband and it's working outside except I need my widget to me showing on the screen " not minimize " + I only can control top left area of my screen since the button that shows the rubber band is on top left.

    how could I use transparent borderless widget ? I'm using qt widget...



  • BTW there is a "desktop screenshot example":http://qt-project.org/doc/qt-5/qtwidgets-desktop-screenshot-example.html in Qt.

    Maybe it will work for you.


Log in to reply
 

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