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. QQuickWidget in Widgets Application
Qt 6.11 is out! See what's new in the release blog

QQuickWidget in Widgets Application

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.4k 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.
  • M Offline
    M Offline
    makzak
    wrote on last edited by
    #1

    Hi,

    i'm developing qt widgets application and I want to add QML object into UI. I'm using QuickWidget like this:

    @QuickWidget::QuickWidget(QWidget *parent)
    : QQuickWidget(parent)
    {
    setSource(QUrl(QStringLiteral("qrc:/test1.qml")));
    }@

    Then I promoted QWidget to QuickWidget. As I run the app, the widget is filled with "UI copy" (have no idea why..) and the QML area is filled with black color like this:

    !http://www.stud.fit.vutbr.cz/~xzakma01/qt/ui1.png(UI1)!

    If I resize the application window, the UI changes and insted of black area the QML file is displayed, but also inside whole UI copy like this:

    !http://www.stud.fit.vutbr.cz/~xzakma01/qt/ui2.png(UI2)!

    Could anyone help me solve this? I tested my code on simple app (only 1 QTabWidget with 2 tabs) an it works great. So the problem is not in non-working QML.

    Thanks for any advice.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      makzak
      wrote on last edited by
      #2

      Ok,

      I did some more investigation and find out the problem is caused with this line:

      @player->setVideoOutput(videoWidget);@

      In the previous tab "Camera" is only one QWidget named videoContainer.
      Here is code I'm using to add video into this QWidget:

      @ // init player
      player = new QMediaPlayer;

      // init playlist
      playlist = new QMediaPlaylist(player);
      
      // add video files from local disk
      playlist->addMedia(QUrl::fromLocalFile("...."));
      playlist->addMedia(QUrl::fromLocalFile("..."));
      
      // playlist index
      playlist->setCurrentIndex(1);
      
      // play in loop
      playlist->setPlaybackMode(QMediaPlaylist::Loop);
      player->setPlaylist(playlist);
      
      // ui video frame
      QWidget *qw = ui->videoContainer;
      
      // init video widget
      videoWidget = new QVideoWidget(qw);
      
      videoWidget->setMinimumSize(400,300);
      
      // THIS CAUSES THE ERROR - assign output widget
      player->setVideoOutput(videoWidget);@
      

      Could this be a bug or am I using it wrong way?
      Thanks for any help.

      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