Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Why the paintevent is not working?
Forum Updated to NodeBB v4.3 + New Features

Why the paintevent is not working?

Scheduled Pinned Locked Moved Solved Qt 6
2 Posts 2 Posters 606 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.
  • C Offline
    C Offline
    Christina123
    wrote on last edited by
    #1

    Hi, I've created two QDialogs and connect them together by using signal and slot in the main.cpp. What I wish to see is that when I draw a line on the first window, it will be displayed on the second one. I am certain that the signal is accepted by the slot as printPath() is able to print out the path. However, the second window is not updated when I call the update() in setPath(). Why is that?

    void Receiver::paintevent(QPaintEvent *e)
    {
        QPainter painter(this);
        painter.drawPath(*path);
    }
    void Receiver::setPath(QPainterPath* inPath)
    {
        path = inPath;
        update();
        printPath();
    }
    
    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      It should be paintEvent, not paintevent. When overriding virtual members use the override keyword in the header. It will help you catch typos like this.

      Also, since you're passing the path through a pointer, make sure that path object is still alive when paintEvent is called, otherwise that's undefined behavior.

      1 Reply Last reply
      4

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved