Qt-interest Archive, March 2002
QCheckListItem example
Message 1 in thread
Greetings, all,
Can someone direct me to the source code which produces the
screenshot in the QCheckListItem documentation?
It looks as though they have a QCheckListItem in column zero, and
some other type of QListViewItem in column 1. I can't figure out how
that's done.
Also, is there a way to hide or turn off the column headers?
Thanks in advance.
Regards,
Jerry Barenholtz
jerryb@saltspring.com
Message 2 in thread
On Thu, 21 Mar 2002 15:42:12 -0800
Jerry Barenholtz <jerryb@saltspring.com> wrote:
> Can someone direct me to the source code which produces the
> screenshot in the QCheckListItem documentation?
>
> It looks as though they have a QCheckListItem in column zero, and
> some other type of QListViewItem in column 1. I can't figure out how
> that's done.
No, the QCheckListItem is a just QListViewItem with a checkbox added on
the left of the first column. You can set the look and behaviour of the
checkbox with the Type argument in the constructor. After that, you just
add text and/or pixmaps on each column with the setText(int, const
QString&) and setPixmap(int, const QPixmap&) methods inherited from
QListViewItem.
For instance, the code for the last two items of the doc example would be
something like
// assuming listview is a QListView* and filePixmap a QPixmap
// create and insert Item Two
QCheckListItem* itemTwo = new QCheckListItem(listview, "Item Two",
QCheckListItem::CheckBox); itemTwo->setText(1, "QCheckListItem
(CheckBox)"); itemTwo->setPixmap(1, filePixmap);
itemTwo->setOn(true);
listview->insertItem(itemTwo);
// create and insert Item One
QCheckListItem* itemOne = new QCheckListItem(listview, "Item One",
QCheckListItem::CheckBox); itemOne->setText(1, "QCheckListItem
(CheckBox)"); listview->insertItem(itemOne);
> Also, is there a way to hide or turn off the column headers?
Yes, QHeader inherits from QWidgert, so you can simply call
listview->header()->hide();
The doc for QListView::header() advises against "changing the header
behind the listview's back", but I am not sure this warning applies to
hiding them. Anyway I am using this in my code and nothing has exploded in
my face yet :)
--
[ signature omitted ]
Message 3 in thread
Greetings,
3/22/2002 1:46:32 AM, Matthieu Dazy <dazy@t-surf.com> wrote:
>No, the QCheckListItem is a just QListViewItem with a checkbox added on
> ... <snip>
Thanks for your comments and especially for your example code
Just what I needed.
And thanks, others, for your responses -- they were on point and
correct.
Regards,
Jerry Barenholtz
jerryb@saltspring.com
Message 4 in thread
First your second question:
myListView->header()->hide();
About your first question, i can't find a screenshot in the QCheckListItem
documentation!?!
Edwin Vroon
-----Original Message-----
From: Jerry Barenholtz [mailto:jerryb@saltspring.com]
Sent: 2002-03-22 00:42
To: Qt-interest
Subject: QCheckListItem example
Greetings, all,
Can someone direct me to the source code which produces the
screenshot in the QCheckListItem documentation?
It looks as though they have a QCheckListItem in column zero, and
some other type of QListViewItem in column 1. I can't figure out how
that's done.
Also, is there a way to hide or turn off the column headers?
Thanks in advance.
Regards,
Jerry Barenholtz
jerryb@saltspring.com
--
[ signature omitted ]