Hi everyone
I am working withr Qt 4.6 (which seems quite buggy), and I would like to know if these errors comes from me, or qt
I would like a qtreewidget, made of children, each children having children. So the design is:
TREE
- Children 1
- Sub Children 1
- Sub Children 2
- Children 2
Here I have my first issue. I successively tried:
tree->setColumnCount(2); //not the point here but I need it
child->setHidden(false); //just to be sure
QTreeWidget* tree = new QTreeWidget(parentwidget); //tree creation
tree->setColumnCount(2); //not the point here but I need it
QTreeWidgetItem* main = new QTreeWidgetItem(tree); //1st level item creation
QTreeWidgetItem* child= new QTreeWidgetItem(main); //2d level item creation, with 'main' as parent
child->setHidden(false); //just to be sure
To copy to clipboard, switch view to plain text mode
and
tree->setColumnCount(2);
main -> addChild(enfant); //link child->parent
child->setHidden(false);
QTreeWidget* tree = new QTreeWidget(parentwidget);
tree->setColumnCount(2);
QTreeWidgetItem* main = new QTreeWidgetItem(tree);
QTreeWidgetItem* child= new QTreeWidgetItem(); //2d level creation, without parent
main -> addChild(enfant); //link child->parent
child->setHidden(false);
To copy to clipboard, switch view to plain text mode
In both cases, I can't see the items but the 1st leveled one.
However with:
tree->setColumnCount(2);
child->setHidden(false);
QTreeWidget* tree = new QTreeWidget(parentwidget);
tree->setColumnCount(2);
QTreeWidgetItem* main = new QTreeWidgetItem(tree);
QTreeWidgetItem* child= new QTreeWidgetItem(tree); //child is created as 1st level item
child->setHidden(false);
To copy to clipboard, switch view to plain text mode
Of course all items are 1st-level items now (which is not what I want), but at least they all are here!
So FIRST QUESTION:
What is wrong with my ways of including children to the 1st level item?
__________________________________________________ __________________________________________________ ________
Then, I am enjoying my all-1st-leveled items. They all are with the design:
[] Name_of_item,
[] being a checkbox.
Then I do:
item ->setCheckState(0,Qt::Checked); //to create the column 0 checkbox
item->setText(1,tr("Name")); //to label the ligne
//blablabla do the same for other items
QTreeWidgetItem* item = new QTreeWidgetItem(tree);
item ->setCheckState(0,Qt::Checked); //to create the column 0 checkbox
item->setText(1,tr("Name")); //to label the ligne
//blablabla do the same for other items
connect( tree , SIGNAL( itemClicked( QTreeWidgetItem*,int ) ), this, SLOT ( updateitem ( QTreeWidgetItem*,int ) ) );
To copy to clipboard, switch view to plain text mode
So there, each item looks exactly as I want it to (which is greeeaaaaat). Let's click the first checkbox! Nothing. The second? Nothing. I am a little bit naive ; "Hum, my slot is buggy... Let's add some breakpoints..." The first one I had is right at the first line of the slot function, so if the slot function is read, the breakpoint is hit. Let's run it again. clic. clic. CLIC. CLIC. "SO why are you not hitting my breakpoint?!!!"
So there is my second question:
Why this tree is not clever enough to understand that when I clic on it, I want the itemClicked signal to be emitted?
Is there a way to solve these issues without having to use an older version of qt? I used qtreewidgets just like that with 4.3 and it worked, so what?!
Thanks,
M.
Bookmarks