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. Transparency of QDeclarativeView containing QML on top of a QWidget playing a video (using either phonon or libvlc).
Forum Updated to NodeBB v4.3 + New Features

Transparency of QDeclarativeView containing QML on top of a QWidget playing a video (using either phonon or libvlc).

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 4.5k 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
    mimeit02
    wrote on last edited by
    #1

    I am currently developing a video player.

    1)
    The GUI as the topmost layer is written in QML.
    It should be transparent to lower layers.

    It contains control elements, some Lists etc.,
    It's displayed using a QDeclarativeView.

    Source extract:

    @ QDeclarativeView *upperLayer = new QDeclarativeView(this);
    upperLayer->setSource(QUrl("/home/projects/QtVideo/qml/videoControl.qml"));
    upperLayer->setStyleSheet(QString("background: transparent");
    upperLayer->setResizeMode(QDeclarativeView::SizeRootObjectToView);
    uperLayer->showFullScreen();@

    2)

    The layer underneath is a QWidget.

    I use the libvlc to display the video content
    in this widget.

    Reason: I am receiving mpeg2-ts, which can not be decoded by phonon, afaik.
    Therefore I need the libvlc to decode the incoming *.ts stream and put the output onto the display.

    Source extract:

    @QWidget *lowerLayer = new QWidget(this);
    lowerLayer.setGeometry(QString("background: red"));
    QUrl* url = new QUrl("file:///home/projects/QtVideo/video.ts");
    libvlc_instance_t*vlcObject;
    libvlc_media_t*vlcMedia;
    libvlc_media_player_t*vlcPlayer;
    
    vlcPlayer = NULL;
    if(vlcObject = libvlc_new(argc, argv)) == NULL)
    {
         printf("Not able to initialize";
         exit(1);
    }
    
    if(vlcPlayer && libvlc_media_player_is_playing(vlcPlayer))
    {
         libvlc_media_player_stop(vlcPlayer);
    }
    
    vlcPlayer = libvlc_media_player_new(vlcObject);
    vlcMedia = libvlc_media_new_location(vlcObject, url.toString().toUtf8().constData());
    libvlc_media_player_set_media(vlcPlayer, vlcMedia);
    
    #if defined(Q_OS_MAC)
         libvlc_media_player_set_nsobject(vlcPlayer, lowerLayer->winId());
    #elif defined(Q_OS_UNIX)
         libvlc_media_player_set_x_window(vlcPlayer, lowerLayer->winId());
    #elif defined(Q_OS_WIN)
         libvlc_media_player_set_hwnd(vlcPlayer, lowerLayer->winId());
    #endif
    
    libvlc_media_player_play(vlc_player);@
    

    Both Elements, the QDeclarativeView and the QWidget
    are embedded in a QMainWindow, lowerLayer created before the upperLayer,
    upperLayer Transparent to the lowerLayer.

    The Problem:

    As long as the lowerLayer is displaying static elements such as a picture, or some colored shapes, everything works fine, full transparency and funtionality.

    As soon as I start displaying a video, such as the described *.ts using the libvlc OR some random video using the Phonon::VideoPlayer, the parts of the upperLayer which are above the video parts of the lowerLayer are displayed in the color of the lowerLayer(default: gray),
    the parts of the upperLayer which are positioned above parts of the lowerLayer or others which do not contain video elements are displayed in correct behaviour.

    Question:

    Is there any posibility and if so, how, to get the upperLayer transparent, even if there is a video playing?

    Kind regards and thanks in advance,

    Michael

    1 Reply Last reply
    0
    • F Offline
      F Offline
      flobe
      wrote on last edited by
      #2

      I had the same problem and after some fiddling about I found out that setting the autoFillBackground property of the viewport to false helps at least for me. I have an ordinary widget underneath tough. Don't know whether it works with a video.

      Just add
      @
      upperLayer->viewport()->setAutoFillBackground(false);
      @ after setting the qml source.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        helldrik
        wrote on last edited by
        #3

        I am experiencing the same problem and
        "upperLayer->viewport()->setAutoFillBackground(false)" doesn`t help.

        Anyone found a solution so far?

        1 Reply Last reply
        0
        • F Offline
          F Offline
          flobe
          wrote on last edited by
          #4

          Can you post a small example?

          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