If you click in the button and no items are selected, ui->treeWidget->currentItem() return NULL.
And when the line ptr->isSelected() is executed, your program crash...
You need to add robustness.
If you click in the button and no items are selected, ui->treeWidget->currentItem() return NULL.
And when the line ptr->isSelected() is executed, your program crash...
You need to add robustness.
smemamian (31st March 2013)
is it true ? :-?
Qt Code:
void MainWindow::on_pushButton_clicked() { for(int i=0 ; i<100 ;i++) { ui->progressBar->setValue(i); } if(ui->treeWidget->currentItem()->isSelected()) { ptr->setBackgroundColor(0,Qt::red); ptr->setBackgroundColor(1,Qt::red); } }To copy to clipboard, switch view to plain text mode
Nop, rather:
Qt Code:
void MainWindow::on_pushButton_clicked() { for(int i=0 ; i<100 ;i++) { ui->progressBar->setValue(i); } if(ptr && ptr->isSelected()) { ptr->setBackgroundColor(0,Qt::red); ptr->setBackgroundColor(1,Qt::red); } }To copy to clipboard, switch view to plain text mode
or use selectedItems().cout() ...
smemamian (31st March 2013)
Seems a rather pointless progress bar. Empty to full in 100 steps over 200 milliseconds... and then do the 'work' in fractions of a millisecond?
Bookmarks