wxDataViewTreeTable adding Columns help Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
izzijaz
Knows some wx things
Knows some wx things
Posts: 49
Joined: Thu Oct 20, 2022 3:34 pm

wxDataViewTreeTable adding Columns help

Post by izzijaz »

Hi,
I have made a wxDataViewTreeCtrl then i created a wxDataViewColumn and called AppendColumn() to the tree. But i dont see any columns on the treeview. How do i use the class to create multiColumn entries along with the features of tree items?
Thanks
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxDataViewTreeTable adding Columns help

Post by ONEEYEMAN »

Hi,
Did you look at the dataview sample?

Thank you.
izzijaz
Knows some wx things
Knows some wx things
Posts: 49
Joined: Thu Oct 20, 2022 3:34 pm

Re: wxDataViewTreeTable adding Columns help

Post by izzijaz »

Trying to compile the sample using

Code: Select all

g++ dataview.cpp `wx-config --cxxflags --libs` -o dataview
Gives me a bunch of undefined references to the treemodel class.
Im running linux btw
izzijaz
Knows some wx things
Knows some wx things
Posts: 49
Joined: Thu Oct 20, 2022 3:34 pm

Re: wxDataViewTreeTable adding Columns help

Post by izzijaz »

maybe its because i have configured for mingw when calling make. There are a lot of dll files in the directory. i may have fogotten about that i will check it out.
sw
Experienced Solver
Experienced Solver
Posts: 56
Joined: Sat Mar 16, 2019 8:09 pm

Re: wxDataViewTreeTable adding Columns help

Post by sw »

Hi,

There is a even more minimalist dataview example here: https://github.com/ifexception/wxdataview-example

Maybe that will help?

Thanks
izzijaz
Knows some wx things
Knows some wx things
Posts: 49
Joined: Thu Oct 20, 2022 3:34 pm

Re: wxDataViewTreeTable adding Columns help

Post by izzijaz »

I have studied the Examples you guys have showed m, thanks for your support.
I have setup my own class of DataViewNode with data for 8 columns and a DataViewModel and setup the virtual classes needed for the DataViewModel as mentioned in the documentation.
I then created a DataVIewControl, associated the Model and added 8 columns into it.
However when i run the application, i can see the 8 columns added but i dont see any of my DataviewNodes being displayed.
izzijaz
Knows some wx things
Knows some wx things
Posts: 49
Joined: Thu Oct 20, 2022 3:34 pm

Re: wxDataViewTreeTable adding Columns help

Post by izzijaz »

sw wrote: Tue Feb 07, 2023 12:47 pm Hi,

There is a even more minimalist dataview example here: https://github.com/ifexception/wxdataview-example

Maybe that will help?

Thanks
Can u explain to me what the getCHildren function is actually doing? What i am trying to do is run a query against an sql Databse to return two kind of items. A normal Item and an item which is a mixture of different items(lets call it Composite items), So the Normal item i have setup to be a root item with no children and i set that as a non container. I have managed to display the root items. I have also added the item to display the Composite item dataItem as a root item but as a container type, but its not showing the appended children. i think its because i dont have a good understanding of how wxWidges uses this functions to fill the table. it would be helpful if someone can explain. I am using linux btw. that may the problem? THanks,
Last edited by izzijaz on Sat Feb 11, 2023 7:52 pm, edited 1 time in total.
izzijaz
Knows some wx things
Knows some wx things
Posts: 49
Joined: Thu Oct 20, 2022 3:34 pm

Re: wxDataViewTreeTable adding Columns help

Post by izzijaz »

Image
I dont even see expanders on the List.
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxDataViewTreeTable adding Columns help

Post by doublemax »

Isn't the very first page of the "dataview" sample (MyMusicTreeModel) what you're looking for?

If you have your own wxDataViewModel, it's important to override wxDataViewModel::HasContainerColumns(...) and wxDataViewModel::IsContainer(...).
Use the source, Luke!
izzijaz
Knows some wx things
Knows some wx things
Posts: 49
Joined: Thu Oct 20, 2022 3:34 pm

Re: wxDataViewTreeTable adding Columns help

Post by izzijaz »

doublemax wrote: Sat Feb 11, 2023 9:19 pm Isn't the very first page of the "dataview" sample (MyMusicTreeModel) what you're looking for?

If you have your own wxDataViewModel, it's important to override wxDataViewModel::HasContainerColumns(...) and wxDataViewModel::IsContainer(...).
I actually did override these functions. My problem is now the nodes which have been appended to my composite Item. They are not being displayed in the control. Only the root nodes are being displayed. Im guessing its not being iterated. How does the Datactrl actually call the getChildren Function? First when the control is empty, im guessing the control calls getChilren() to retreive the nodes. So I have made an if function, if the item.isok() is null that means control is empty, so add the root items into the list whether it be a composite item(container) and append its children or add a normal item without children. It works up to the root entries. But the children for the container is where the problem is now. There is no expander near the composite entry, no children is being displayed which were appended to the Node. Note i have right below the if statementi just mentioned, i have added the code to retreive children also.

Code: Select all

unsigned int count = node->GetChildren().GetCount();
    for (unsigned int pos = 0; pos < count; pos++)
    {
        MyMusicTreeModelNode *child = node->GetChildren().Item( pos );
        array.Add( wxDataViewItem( (void*) child ) );
    }

    return count;
izzijaz
Knows some wx things
Knows some wx things
Posts: 49
Joined: Thu Oct 20, 2022 3:34 pm

Re: wxDataViewTreeTable adding Columns help

Post by izzijaz »

doublemax wrote: Sat Feb 11, 2023 9:19 pm Isn't the very first page of the "dataview" sample (MyMusicTreeModel) what you're looking for?

If you have your own wxDataViewModel, it's important to override wxDataViewModel::HasContainerColumns(...) and wxDataViewModel::IsContainer(...).
Shortly after posting, i have managed to fix this issue. There was a mistake in the append function which made the function return without adding into the array. #-o .

There is one question i still have. I had a mistake in the getParent() function which fixed but want to know the reason why it happened. See this gif.
Image
my code is as follows:

Code: Select all

wxDataViewItem itemListDataModel::GetParent(const wxDataViewItem &item) const{
    if(!item.IsOk()){
        return wxDataViewItem(0);
    }
    itemListNode* node = (itemListNode*)item.GetID();

    if (!node->node_isComposite)return wxDataViewItem(0); //this peice of code causes the table to behave strange.

    return wxDataViewItem((void*)node->getParent());
}
it causes items in the table to flicker, and also disappear when the node is expanded and then returns back after mouse hover. it was very strange.
i also got a msg on the debug.

Code: Select all

Gtk-CRITICAL **: 11:23:44.768: ../../../../gtk/gtktreeview.c:5048 (gtk_tree_view_bin_expose): assertion `has_parent' failed.
There is a disparity between the internal view of the GtkTreeView,
and the GtkTreeModel.  This generally means that the model has changed
without letting the view know.  Any display from now on is likely to
be incorrect.
removing that line fixes the issue. My question is why was is casuing this issue. If the node is not a container, then why would returning a wxDataViewItem(0) cause this issue? is there a difference between wxDataViewItem(0) and wxDataViewItem((void*)node->getParent())? if the item is not a container the parent will be null. so is 0.
Post Reply