painter event and combo box to draw lines
Solved
General and Desktop
-
Hi,
I have a
paintEvent
to draw lines. There is a ComboBox to select to draw line 1 or 2 . For ex. if the Combobox index is 0 draw line 1 or index 1 draw line 2. I did as followsvoid MainWindow::paintEvent(QPaintEvent *e) { QPainter painter1(this); QPen linepen1(Qt::darkRed); linepen1.setWidth(2); int comboVal = 0; comboVal = ui->comboBox->currentIndex(); // combo box value switch (comboVal) { case 0: painter1.setPen(linepen1); painter1.drawLine(p11,p12); break; case 1: painter1.setPen(linepen1); painter1.drawLine(p11,p13); break; } }
The problem is that drawing is not "real-time" when selecting the Combobox index. Do you see an issue here?