Thanx a lot! I see what's wrong. There's a label in the project:
void MainWindow::on_treeWidget_itemSelectionChanged()
{
ui->label->setText( ui->treeWidget->currentItem()->text(0) );
}
void MainWindow::on_treeWidget_itemSelectionChanged()
{
ui->label->setText( ui->treeWidget->currentItem()->text(0) );
}
To copy to clipboard, switch view to plain text mode
it just show the name of which is selected. When nothing is available it crashes.
Then I tried this and failed again:
void MainWindow::on_treeWidget_itemSelectionChanged()
{
if(ui->treeWidget->topLevelItemCount()>0)
ui->label->setText( ui->treeWidget->currentItem()->text(0) );
}
void MainWindow::on_treeWidget_itemSelectionChanged()
{
if(ui->treeWidget->topLevelItemCount()>0)
ui->label->setText( ui->treeWidget->currentItem()->text(0) );
}
To copy to clipboard, switch view to plain text mode
I think when the treeWidget is empty all the members of it are unavailabe. But just how to keep it away from crashing if I still want to use this label?
Bookmarks