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 receive signal from a static member functions?
Qt 6.11 is out! See what's new in the release blog

How to receive signal from a static member functions?

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

    Hi,all!
    In my pragram, I used the vlc to make a media player.
    I use the libvlc_event_attach to receive the event emit from vlc library,code as below:
    [code]
    void VLCMediaPlayerPrivate::setMedia(const QMediaContent &media)
    {

    QString mrl = media.canonicalUrl().toString();

    m_vlcMedia = libvlc_media_new_path( m_vlcInstance, mrl.toAscii());

    if (m_vlcMedia) {
    libvlc_event_manager_t *vlcEventManager = libvlc_media_event_manager(m_vlcMedia);
    if (vlcEventManager) {
    libvlc_event_attach(vlcEventManager, libvlc_MediaDurationChanged, durationChanged, this);
    }
    }
    // Put the media into the mediaplayer
    libvlc_media_player_set_media( m_vlcMediaPlayer, m_vlcMedia);
    }
    [/code]
    durationChanged is a static member function of class VLCMediaPlayerPrivate,and I passed the this pointer as user data to the libvlc_event_attach.And the durationChanged implements:
    [code]
    void VLCMediaPlayerPrivate::durationChanged(const struct libvlc_event_t event, void data)
    {
    if (data) {
    VLCMediaPlayerPrivate
    pthis = (VLCMediaPlayerPrivate
    )data;
    if (event->type == libvlc_MediaDurationChanged)
    pthis->emitDurationChanged(static_cast<qint64>(event->u.media_duration_changed.new_duration));
    }
    }
    [/code]
    emitDurationChanged is a non-static member function to emit a qt singals as belows:
    [code]
    void VLCMediaPlayerPrivate::emitDurationChanged(qint64 duration)
    {
    Q_Q(VLCMediaPlayer);
    m_duration = duration;
    Q_EMIT q->durationChanged(m_duration);
    }
    [/code]
    But I can't receive the durationChanged single, seems not working, this is why?

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hooleego
      wrote on last edited by
      #2

      Anybody help?

      1 Reply Last reply
      0
      • raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

        what exactly doesn't work?
        Where is your connect() statement?
        Any output on the console?

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        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