Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-132094

Issue: Mac OS: other widget cannot show when use SDL_CreateWindowFrom() to bind a widget

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 5.15.16
    • GUI: OpenGL
    • None
    • MACOS + M2 CPU
    • macOS

    Description

      I am using QT 5.15.16 + SDL 2.30.10 for testing, right now I create 2 widgets, one widget call video widget use to display YUV data, other widget call control widget which has some PushButtons.

      on the video widget, use SDL_CreateWindowFrom() to bind this widget, and want to show YUV data via SDL_RenderCopy/SDL_RenderPresent API.

      when render it on macOS, the control widget desn't work, it just show black. what is problem? is it the known issue on QT?
      this code can work fine on Windows + Ubuntu.

       

      #include "mainwindow.h"
      #include "ui_mainwindow.h"

      #include <thread>
      #include <QTimer>
      #include <QDebug>

      MainWindow::MainWindow(QWidget *parent)
          : QMainWindow(parent)
          , ui(new Ui::MainWindow)

      {     ui->setupUi(this);     SDL_Init(SDL_INIT_VIDEO);     window = nullptr;     render = nullptr;     window= SDL_CreateWindowFrom((void *)ui->video->winId());     render = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);     QTimer *timer = new QTimer(this);     connect(timer, &QTimer::timeout, this, &MainWindow::renderYUV);     timer->start(1000 / 30); }

      void MainWindow::renderYUV()
      {
          SDL_Rect rect = {};

          width = ui->video->width();
          height = ui->video->height();

          qDebug() << "w :" << width << " h:" << height;

          yPlane = new uint8_t[width * height]; // Y plane
          uPlane = new uint8_t[width * height / 4]; // U plane
          vPlane = new uint8_t[width * height / 4]; // V plane

          // fill YUV data
          for (int i = 0; i < width * height; ++i)

      {         yPlane[i] = 128; // Y     }

          for (int i = 0; i < width * height / 4; ++i)

      {         uPlane[i] = 128; // U         vPlane[i] = 128; // V     }

          SDL_Texture *texture = SDL_CreateTexture(render, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING, width, height);
          if (!texture)

      {         qDebug() << "Failed to create texture: " << SDL_GetError();         return;     }

          SDL_UpdateTexture(texture, nullptr, yPlane, width);

          SDL_RenderClear(render);

          rect.x = 0;
          rect.y = 0;
          rect.w = ui->video->width();
          rect.h = ui->video->height();

          qDebug() << "display rect x " << rect.x << " y " << rect.y << " w " << rect.w  << " h " << rect.h;test.zip

          SDL_RenderCopy(render, texture, nullptr,  &rect);

          SDL_RenderPresent(render);

          SDL_DestroyTexture(texture);
      }

      MainWindow::~MainWindow()

      {     delete ui; }

      Attachments

        1. qt_log.txt
          59 kB
          Figo 1802
        2. test.zip
          8 kB
          Figo 1802
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            lagocs Laszlo Agocs
            figo Figo 1802
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes