查看完整版本: [-- 关于update后没有调用paintevent的问题 --]

QTCN开发网 -> Qt基础编程 -> 关于update后没有调用paintevent的问题 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

lijiebit 2017-09-22 20:25

关于update后没有调用paintevent的问题


VLCPlayer继承自QWidget,用于播放视频,视频解码一帧后调用updatePicture函数执行update,


然后应该执行paintEvent函数,但是程序运行一段时间会无法执行paintEvent函数,导致VLCPlayer无法刷新

如果将程序最小化再最大化就可以刷新,但无法连续刷新,不知道为什么,我用QT5.7.0


void *VLCPlayer::lock(void *op, void **plane)
{
    TCallbackParam *p = (TCallbackParam *)op;
    p->mutex.lock();
    *plane = p->pixels;

    return NULL;

}

void VLCPlayer::unlock(void *op, void *pic, void * const *plane)
{
    TCallbackParam *p = (TCallbackParam *)op;
    uchar *pp = (uchar *)*plane;
    unsigned char *data = (unsigned char *)*plane;
    QImage a(data, p->width, p->height, QImage::Format_RGBA8888);
    p->mutex.unlock();
    p->wnd->updatePicture(a);
}
void VLCPlayer::display(void *op, void *pic)
{
    //    (void)op;
}
void VLCPlayer::updatePicture(const QImage& imageSrc)
{
   this->image = imageSrc;
    update();
}

void VLCPlayer::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
  painter.drawImage(this->rect(), image);
}

fu22507411 2017-09-22 23:59
repaint试试

lijiebit 2017-09-23 20:44
repaint也许是正确的,update是postevent,repaint是sendevent,

在没有调用paintevent的时候,我单步调试进入update,跟踪代码发现调用了postevent,可就是不执行paintevent,很奇怪,主要还是想知道为什么,


查看完整版本: [-- 关于update后没有调用paintevent的问题 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled