Something seems wrong while dragging QSplitter?

186 Views Asked by At

A qsplitter has been used in my application, and OpaqueResize is set to 'false',while dragging the splitter handle, the widget becoming smaller is repainted continuously, this is not right. What I thought is that the QWidgets on both sides of the splitter handle should not receive any signals about repaint or resize until mouseRelease.This issue troubles me several days, if anyone knows about how to deal with it, please give me a hand, thank you. Qt5.11.2 on Windows10 64-bits

MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    // left
    ui->widget_2->bgColor = QColor(255,0,0);
    ui->widget_2->tag     = 0;

    // right
    ui->widget_3->bgColor = QColor(0,0,255);
    ui->widget_3->tag     = 1;
}

MainWindow::~MainWindow()
{
    delete ui;
}

MyWidget::MyWidget(QWidget *parent) : QWidget(parent)
{
    bgColor = QColor(255,255,255);
    tag     = 0;
}

void MyWidget::paintEvent(QPaintEvent *event)
{
    QWidget::paintEvent( event );
    QPainter painter(this);
    QBrush brush( bgColor );
    painter.fillRect( event->rect(), brush );

    qDebug() << "paintEvent:tag="<<tag;
}
0

There are 0 best solutions below