[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

pl.comp.programming

Qt 4, QListView + custom tree model

PlusMinus

5/1/2007 8:52:00 AM

Witam!

Probuje teraz zrobic model drzewa majac nastepujaca struktury danych:
class KlasaGlowna
{
QString nameKG;
QList <QString> lista1;
QList <QString> lista2;
QList <QString> lista3;
}
KlasaGlowna posiada powiedzmy 3 listy obiektow typu QString, aczkolwiek
nalezy zalozyc, ze dla kazdej z list jest inny typ, ale cecha wspolna
obiektow przechowywanych w listach, jest to, ze kazdy z nich ma swoje pole
typu QString name, ktore mozna sobie porac poprzez getName(), takze w sumie
dla uproszczenia, sa 3 listy typu QString.

W obiekcie QTreeView chcialbym uzyskac nastepujacy widok:
nameKG
|___lista1
| |__obiekt1_name_w_lista1
| |__obiekt2_name_w_lista1
|___lista2
|___lista3
|__obiekt1_name_w_lista3

Aby stworzyæ model read only potrzebuje zaimplementowaæ nastepujace metody
wirtualne z klasy QAbstractItemModel: index, parent, rowCount, columnCount i
data;

Jako, ze potrzebuje tylko 1 kolumny, implementacja int columnCount(const
QModelIndex &parent) const; jest trywialna, po prostu return 1 i tyle.

Niestety nie mam pomyslu jak wyzej przedstawionej struktury danych
zaimplementowac reszte metod, tj:
QModelIndex index(int row, int column, const QModelIndex &parent) const;
QModelIndex parent(const QModelIndex &child) const;
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;

za wszelkie sugiestie wielkie dzieki
TmP


5 Answers

Spartakus

4/1/2009 4:02:00 PM

0

nob...@nospam.pacbell.net (Bill Z.) wrote:
> Spartakus <sparta...@my-deja.com> writes:

> > My posting handle is a movie reference, not a political reference.
> > Two movies, as a matter of fact.
> >
> > I AM SPARTAKUS!!!

> As an aside, in Latin as spoken 2000+ years ago, there was no "k" but
> rather a 'c' which was pronounced the way we pronounce a 'k'. Hence,
> the correct spelling is Spartacus. :-)

Actually, when I originally set up my account on deja-news.com,
Spartacus with a "c" was already taken. The unusual spelling helps
with Google searches for responses to my posts. Anyway IIRC,
Spartacus was a Greek slave. I don't believe that "c" appears in the
Greek alphabet, so the "k" is more authentic. :-)

Spartakus

4/1/2009 4:09:00 PM

0

Stan de SD <StanD...@gmail.com> wrote:

> Keeping people helpless and dependent on government is NOT compassion.

Conservative policies have the effect of MAKING people helpless and
dependent.

> Telling people that they can't make it on their own, that the system
> is stacked against them, so they shouldn't try to do their best, is
> NOT compassion.

Conservative policies are focused entirely on benefitting people who
are already well off. They rig the system *against* people who are
trying to make it on their own.

Stan de SD

4/1/2009 8:13:00 PM

0

On Apr 1, 9:09 am, Spartakus <sparta...@my-deja.com> wrote:
> Stan de SD <StanD...@gmail.com> wrote:
>
> > Keeping people helpless and dependent on government is NOT compassion.
>
> Conservative policies have the effect of MAKING people helpless and
> dependent.

Really? how?

>
> > Telling people that they can't make it on their own, that the system
> > is stacked against them, so they shouldn't try to do their best, is
> > NOT compassion.
>
> Conservative policies are focused entirely on benefitting people who
> are already well off.  They rig the system *against* people who are
> trying to make it on their own.

Does that explain why wealthy Democrats who send their children to
private schools, and the NEA (a huge lobbying organization donating
millions to Democrat candidates) fight school choice for black
schoolchildren in DC? They are really conservatibes?

Spartakus

4/4/2009 2:46:00 PM

0

Justin Case <JC...@nospam.jitb.com> wrote:
> Spartakus <sparta...@my-deja.com> wrote:

> > Conservative policies are focused entirely on benefitting people
> > who are already well off.  They rig the system *against* people
> > who are trying to make it on their own.

> Spoken like a true Marxist.

Five words in your response, and the only word you go right was "true".

Spartakus

4/4/2009 2:56:00 PM

0

Stan de SD <StanD...@gmail.com> wrote:
> Spartakus <sparta...@my-deja.com> wrote:
> > Stan de SD <StanD...@gmail.com> wrote:

> > > Keeping people helpless and dependent on government is NOT compassion.

> > Conservative policies have the effect of MAKING people helpless and
> > dependent.

> Really? how?

Look at the results.

> > > Telling people that they can't make it on their own, that the system
> > > is stacked against them, so they shouldn't try to do their best, is
> > > NOT compassion.

> > Conservative policies are focused entirely on benefitting people who
> > are already well off.  They rig the system *against* people who are
> > trying to make it on their own.

> Does that explain why wealthy Democrats who send their children to
> private schools, and the NEA (a huge lobbying organization donating
> millions to Democrat candidates) fight school choice for black
> schoolchildren in DC? They are really conservatibes?

Ah, "school choice", the initiative that throws the public education
system under the bus. A perfect example of what I am talking about.
It's not just the NEA and "wealthy Democrats" who oppose "school
choice". For example, the Anti-Defamation League is against it:

http://www.adl.org/vouchers/voucher...

And "school choice" has been voted down in 18 out of the 20 states
where it has appeared on the ballot. It's one of those ideas that
seems reasonable at first glance, but the closer people look, the more
sordid details they see and the more they dislike it.