QWinTaskbarButton and QWinThumbnailToolBar



  • Now,I am learning Qt example called music player;But there is a problem when i use QWinTaskbarButton and QWinThumbnailToolBar in my own project. Code is under here;

    void  LuoMusic::createThumnail()
    {
      _taskbarbutton = new QWinTaskbarButton( this);
      _taskbarbutton->setWindow(windowHandle());
    
      _taskbarprogress = _taskbarbutton->progress();
      connect(_position_Slider,QSlider::valueChanged,_taskbarprogress,QWinTaskbarProgress::setValue);
      connect(_position_Slider,QSlider::rangeChanged,_taskbarprogress,QWinTaskbarProgress::setRange);
    
      connect(&_player,QMediaPlayer::stateChanged, this, LuoMusic::updateTaskbar);
    
      _thumbnaibar = new QWinThumbnailToolBar(this);
      _thumbnaibar->setWindow(windowHandle());
    
      _thumbnaibar_play = new QWinThumbnailToolButton(_thumbnaibar);
      _thumbnaibar_play->setEnabled(false);
      _thumbnaibar_play->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
      _thumbnaibar_play->setToolTip(tr("play"));
      connect(_thumbnaibar_play,QWinThumbnailToolButton::clicked,this,LuoMusic::updatePlayState);
    
      _thumbnaibar_back = new QWinThumbnailToolButton(_thumbnaibar);
      _thumbnaibar_back->setEnabled(false);
      _thumbnaibar_back->setIcon(style()->standardIcon(QStyle::SP_MediaSeekBackward));
      _thumbnaibar_back->setToolTip(tr("SeekBackward"));
      connect(_thumbnaibar_back,QWinThumbnailToolButton::clicked,this,LuoMusic::SeekBackward);
    
      _thumbnaibar_forward = new QWinThumbnailToolButton(_thumbnaibar);
      _thumbnaibar_forward->setEnabled(false);
      _thumbnaibar_forward->setIcon(style()->standardIcon(QStyle::SP_MediaSeekForward));
      _thumbnaibar_forward->setToolTip(tr("SeekForward"));
      connect(_thumbnaibar_forward,QWinThumbnailToolButton::clicked,this,LuoMusic::SeekForward);
    
      _thumbnaibar->addButton(_thumbnaibar_back);
      _thumbnaibar->addButton(_thumbnaibar_play);
      _thumbnaibar->addButton(_thumbnaibar_forward);
    
      connect(&_player, QMediaPlayer::positionChanged, this, LuoMusic::updateThumbnailToolBar);
      connect(&_player, QMediaPlayer::durationChanged, this, LuoMusic::updateThumbnailToolBar);
      connect(&_player, QMediaPlayer::stateChanged, this,    LuoMusic::updateThumbnailToolBar);
    
    }
    

    called this function in constructor ,but there is nothing while runing the app.On my pc can not see _taskbarbutton and others.

    [Edit: Added code tags ~kshegunov]



  • @chaochao

    thumbnail won't be visible until you hover at your widget in the taskbar and you have setEnabled to false set it to true



  • @Ahti I find it;
    _taskbarbutton->setWindow(windowHandle());
    cause windowHandle() will return NULL;
    But why?
    In manual , QWidget::windowHandle() returns a valid instance of a QWindow only after the widget has been shown.So,what is the time?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.