Hi,
i need a folderbrowser with QDirModel in my Application, but i need to add my own icons (toplevel as well as subentries) (for network access for example). Is there an easy way to do this?
thank you very much in advance
Hi,
i need a folderbrowser with QDirModel in my Application, but i need to add my own icons (toplevel as well as subentries) (for network access for example). Is there an easy way to do this?
thank you very much in advance
No, there is no easy way to do that. For a non-trivial solution search the forum - the problem has been raised at least two times before.
i did search and did not find anything (search terms: Qdirmodel, insert items, insert icons, qtreeview items) - could you point me to the thread(s) please?
Try "subclass QDirModel".
ah thank you very much , i have found something according to my needs.
if i encounter further problems (which will be most likely the case) i will ask again
ok now i subclassed QDirModel::data and QDirModel::rowCount as following:
Qt Code:
{ } { { if(role == Qt::DisplayRole) if(role == Qt::DecorationRole) } }To copy to clipboard, switch view to plain text mode
it does work, however i cannot add an item at the toplevel, only as subentries of other items... I use a treeview to display this, how can i get my item as a toplevel?
edit: the problem seems to be: rowcount isnt called at toplevel
edit 2: it is called... why doesnt it show my additional item then((
Last edited by heinz32; 11th May 2008 at 17:02.
Qt Code:
To copy to clipboard, switch view to plain text mode
should be:
Qt Code:
To copy to clipboard, switch view to plain text mode
Rows are numbered from 0 to rowCount()-1 inclusive.
does not change anything, it now just replaces the ".." (because rowcount returns 1 at toplevel) of every folder with my item but still no extra toplevel item
Because you should check the parent as well![]()
yes but thats not the problem, it does not add any extra items it just replaces the ones which are already there, if i do the parentcheck nothing happens at all
edit: i did a check, MyDirModel::data is only called for the one regular row there, not for my additional one. how can i tell Qtreeview to request that one?
Last edited by heinz32; 11th May 2008 at 22:50.
ok i think the problem is that i have to subclass index() too, because the treeview does request my additional row there. However, i do not know what to return - if i return an index from another item already existing in Qdirmodel, it adds that one, but if i return my own index created with createIndex, the program just crashes ... is there really no solution for this? i would consider this a very basic requirement but it just wont work![]()
Bookmarks