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. Qrect on frame mouse click event
Forum Updated to NodeBB v4.3 + New Features

Qrect on frame mouse click event

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.1k Views
  • 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.
  • N Offline
    N Offline
    Npsad
    wrote on last edited by
    #1

    I did qrect through frame and now I want mouseclick event on that qrect.
    Qpainter p(this);
    Qpainter path;
    Path.addRoundRect(1,394,80,20),10,10);
    Qpen pen(Qt::black,10);
    p.setPen(pen);
    p.fillPath(path,Qt:: white);
    p.drawPath(path);

    To this coordinates mousepress event should happen. Any solution on this please:)

    jsulmJ 1 Reply Last reply
    0
    • N Npsad

      I did qrect through frame and now I want mouseclick event on that qrect.
      Qpainter p(this);
      Qpainter path;
      Path.addRoundRect(1,394,80,20),10,10);
      Qpen pen(Qt::black,10);
      p.setPen(pen);
      p.fillPath(path,Qt:: white);
      p.drawPath(path);

      To this coordinates mousepress event should happen. Any solution on this please:)

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Npsad Mouse click event on the widget you're painting on (this) and check mouse cursor coordinates in that event.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      N 1 Reply Last reply
      3
      • jsulmJ jsulm

        @Npsad Mouse click event on the widget you're painting on (this) and check mouse cursor coordinates in that event.

        N Offline
        N Offline
        Npsad
        wrote on last edited by
        #3

        @jsulm I just printed co-ordinates and now at that particular coordinate only it should display say message box
        So event->pos() at that particular coordinate how to set.. any function we can use

        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