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. Mouse problem in QGraphicsItem

Mouse problem in QGraphicsItem

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 624 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.
  • I Offline
    I Offline
    Isiodos
    wrote on last edited by
    #1

    Hello everyone.
    First of all I am new in qt and c++ graphics.
    I had to read a file and make a gui with that..
    For example i had the file
    rectangle 1 height 5.4 & some info
    rectangle 2 height 2.3 & some other info etc
    rectangle 3 height 6.2 & some other info etc
    ....

    To make them i call and overwritten class like the follow
    @class myNewClass : public QGraphicsItem
    {
    public:
    myNewClass( MyData ); //where MyData is the height color etc info
    QRectF boundingRect() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
    QWidget *widget);

    protected:

    void mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent );
    }@

    I wanted when someone clicks on a rectangle to display a msg with some more info i have and i cant display..

    In the begin nothing works :( then i realized that QRectF boundingRect() const; must have the bounds where i want the mouse to be pressed for every item (correct me if i am wrong but it almost works)

    The problem is that if the rectangle is very large the mouse works only in a smaller area and not all over the rectangle. For example in the 2/3 of it. Also the redraw does not renew correctly in these area.

    NOTE : I display it with negative numbers for example the
    1st rect is from 0 to -height1
    2nd rect is from -sum_height to -height2
    etc

    i put this values in QRectF boundingRect() { return QRectF(my_values); }
    and
    painter->drawRect(myvalues);

    where myvalues is the read values i take from Mydata

    SOLVED
    EDIT :
    When i put
    return QRectF(0,0, X,-7000) did not work
    return QRectF(0,-7000, X,7000) worked

    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