Important: Please read the Qt Code of Conduct -

[Solved]Paint issue in Widget

  • I'm trying my hands on clock in Widget from the reference "digiclock example":

    we intended to improvise the project with other functionalities, so I begun with adding colon between the digits( for example 10:30), though am drawing the rectangle on the paint event. I'm not able see them on the screen.

    Below is the code snippet, i have tried to introduce a plane rectangle on paint event but its not visible on the screen

    @void DrawingDigits::paintEvent(QPaintEvent *event) {

    QPainter painter(this);
    if (m_animator.state() == QTimeLine::Running) {
    } else {


    Can anyone please let me know where am getting it wrong (Kindly refer the link for the complete code in case needed). I'm not getting any warning while debugging.

  • Moderators

    I would suspect that after you draw your rectangle, the paintFlip() and paintStatic() methods are repainting the entire area, covering up the rectangle you just drew.

  • ohh yes...those methods are painting the entire area, I should have thought in that area
    Thanx a ton mate :)

  • Moderators

    No problem! Be sure and edit your first post and add [Solved] to the title. Thanks!

Log in to reply