Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to change application window z index
QtWS25 Last Chance

How to change application window z index

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
iosqquickitemqquickwindow
1 Posts 1 Posters 844 Views
  • 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.
  • W Offline
    W Offline
    Wiru
    wrote on 22 Jan 2019, 09:55 last edited by
    #1

    I was trying to get native iOS player as a custom QML component and managed to do it thanks to this. However I'm facing a problem with z order of the component.

    Component constructor:

    MyVideoView::MyVideoView(QQuickItem *parent /*= 0*/)
        : QQuickItem(parent)
        , m_view(0)
    {
        connect(this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(onWindowChanged(QQuickWindow*)));
        connect(this, SIGNAL(visibleChanged()), this, SLOT(onVisibleChanged()));
    }
    

    onWindowChanged implementation:

    void MyVideoView::onWindowChanged(QQuickWindow* window)
    {
        if(!m_view) {
        }
        if (window != 0) {
    
            UIView *parentView = reinterpret_cast<UIView *>(window->winId());
    
                    AVPlayer *_player;
                    AVURLAsset *_asset;
                    AVPlayerItem *_playerItem;
                    AVPlayerLayer *m_playerLayer;
    
                    _player = [[AVPlayer alloc] init];
                    NSURL *baseURL = [[NSURL alloc] initWithString: @"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
                    _asset = [AVURLAsset assetWithURL:baseURL];
                    _playerItem = [AVPlayerItem playerItemWithAsset: _asset];
                    [_player replaceCurrentItemWithPlayerItem:_playerItem];
                    m_playerLayer = [AVPlayerLayer playerLayerWithPlayer:_player];
    
                    m_playerLayer.frame = CGRectMake(this->x(), this->y(), this->width(), this->height());
    
                    [parentView.layer addSublayer:m_playerLayer ];
    
                    [_player play];
    
    
        } else {
            [m_view removeFromSuperView];
        }
    }
    

    Whit this I can use the component in my application which is an ApplicationWindow, but the issue is, the component is always on top, covering the whole application even if I set:

    MyVideoView {
        z:-3
        width: 300
        height: 200
        x:20
        y:300
    }
    

    Or put z of another component to e.g. 300.
    I assume it's because of QQuickWindow or caused by UIView.
    MyVideoView is placed inside an Item component

    What I would want to achieve is to:

    • either make it possible to set the components z order
    • or get the component "behind" the application (creating transparent part on my app so the video is visible, not the best solution but I'm running out of options)

    Is there any way to achieve one of those, or can it be done if the component is something else besides a QQuickItem, since the only part I actually need is the player layer, as I'll create a custom playback control interface?

    1 Reply Last reply
    0

    1/1

    22 Jan 2019, 09:55

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved