fellobo
2nd May 2006, 17:52
Question one:
I have a QTreeWidget with items and I want to grab the collapsed/expanded but it returns a QModelIndex. So how do I grab a collapse or expand that will give me back a QTreeWidgetItem? All the post I've read about this never really answered the question!
Question two:
How do you remove the column at the top? I only have one column and I don't like seeing the 0 at the top of the column. I've searched the doc's but might be missing it or it might be something done in QTDesigner.
Question three:
The following code was how I was thinking of changing the icon from open to close an image is there a better way?
p_tree_widget->setColumnCount(1);
connect(p_tree_widget, SIGNAL(collapsed(QModelIndex &)), this, SLOT(collapsed(QModelIndex &)));
connect(p_tree_widget, SIGNAL(expanded (QModelIndex &)), this, SLOT(expanded (QModelIndex &)));
QTreeWidgetItem *p_folder = new QTreeWidgetItem(project_tree);
p_folder->setText(0, tr("Content"));
p_folder->setIcon(0, QIcon(":/images/closed_folder.png"));
QTreeWidgetItem *p_data = new QTreeWidgetItem(project_tree);
p_data->setText(0, tr("data"));
p_data->setIcon(0, QIcon(":/images/data.png"));
void collapsed ( const QModelIndex &index )
{
// get QTreeWidgetItem
p_collapsed->setIcon(0, QIcon(":/images/closed_folder.png"));
};
void expanded ( const QModelIndex &index )
{
// get QTreeWidgetItem
p_collapsed->setIcon(0, QIcon(":/images/open_folder.png"));
};
Thanks for any help that you may give me!
I have a QTreeWidget with items and I want to grab the collapsed/expanded but it returns a QModelIndex. So how do I grab a collapse or expand that will give me back a QTreeWidgetItem? All the post I've read about this never really answered the question!
Question two:
How do you remove the column at the top? I only have one column and I don't like seeing the 0 at the top of the column. I've searched the doc's but might be missing it or it might be something done in QTDesigner.
Question three:
The following code was how I was thinking of changing the icon from open to close an image is there a better way?
p_tree_widget->setColumnCount(1);
connect(p_tree_widget, SIGNAL(collapsed(QModelIndex &)), this, SLOT(collapsed(QModelIndex &)));
connect(p_tree_widget, SIGNAL(expanded (QModelIndex &)), this, SLOT(expanded (QModelIndex &)));
QTreeWidgetItem *p_folder = new QTreeWidgetItem(project_tree);
p_folder->setText(0, tr("Content"));
p_folder->setIcon(0, QIcon(":/images/closed_folder.png"));
QTreeWidgetItem *p_data = new QTreeWidgetItem(project_tree);
p_data->setText(0, tr("data"));
p_data->setIcon(0, QIcon(":/images/data.png"));
void collapsed ( const QModelIndex &index )
{
// get QTreeWidgetItem
p_collapsed->setIcon(0, QIcon(":/images/closed_folder.png"));
};
void expanded ( const QModelIndex &index )
{
// get QTreeWidgetItem
p_collapsed->setIcon(0, QIcon(":/images/open_folder.png"));
};
Thanks for any help that you may give me!