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. How to call paintEvent
Qt 6.11 is out! See what's new in the release blog

How to call paintEvent

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 16.9k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I need to display an IplImage (OpenCV structure) I can't use QPixmap because I am updating from another thread which gives me an error that it's unsafe.Now I am using paintEvent

    I am using Signals and Slots , Here is the Slot where I receive the image:

    @void MainWindow::Show(IplImage *frame)
    {
    img = QImage(QSize(frame->width,frame->height),QImage::Format_RGB888);
    // I need to show img now on ui->frame
    // if I use this->update it show a strange image !!

    }@

    Here is the paint event:

    @void MainWindow::paintEvent(QPaintEvent *)
    {
    QPainter painter(this);

    painter.drawImage(QPoint(ui->frame->x(),ui->frame->y()),img);
    

    }
    @

    but I don't know how to call the paint event.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Simply call QWidget::update() from MainWindow Show method and you'll be done !

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        sorry I updated the post , when using this->update It shows me a strange picture not the one caming from the cam, actually it's the same but with strange colors

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Ok, then try to play with the QImage::format. Are you sure your IplImage is internally stored as 38 bits RGB ? Coulnd't it be a 38 bits BGR image ?

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            Also check the type of RGB values (unsigned, signed, float)

            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