Qt-interest Archive, April 2007
[Qt4.3/Mac] Missing focus indicator in QTreeWidget
Message 1 in thread
In my application I have a dialog with a QTreeWidget that allows the
user to mark several items as selected, as well as deleting items
via a "Delete" button. This all works nicely on Linux and Windows,
but there is a problem on the Mac, because the user has no clue as
to which item is the current one.
Please take a look at the attached example.
It opens a window with a QTreeWidget and a "Delete" button.
The button deletes whichever list item is current at the moment.
setAllColumnsShowFocus() is set to have all columns show the focus
(however, this only works on Linux and Windows).
Now run this program on a Mac and see that you have no clue as to
which item will actually be deleted when you press the "Delete"
button. I can't imagine that there is a design guideline that
says "Mac users don't need to see what they are going to delete" ;-),
but Trolltech is persistently refusing to do something about this.
Is this something others also have a problem with, or is this type
of dialog totally "non-Mac-like"?
Klaus Schmidinger
#include <qapplication.h>
#include <qapplication.h>
#include <qdialog.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qitemdelegate.h>
#include <qtreewidget.h>
class ItemDelegate : public QItemDelegate
{
public:
ItemDelegate(QObject *parent = NULL)
:QItemDelegate(parent) {}
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyleOptionViewItem opt = option;
if (index.column() != 0)
opt.state &= ~QStyle::State_Selected;
QItemDelegate::paint(painter, opt, index);
}
};
class cSelectTree : public QTreeWidget {
Q_OBJECT
public slots:
void Delete(void);
public:
cSelectTree(QWidget *parent);
};
cSelectTree::cSelectTree(QWidget *parent)
:QTreeWidget(parent)
{
setAllColumnsShowFocus(true);
setItemDelegate(new ItemDelegate(this));
setColumnCount(2);
QTreeWidgetItem *h = headerItem();
h->setText(0, "Nr");
h->setText(1, "Name");
setSelectionMode(QAbstractItemView::MultiSelection);
for (int i = 0; i < 10; ++i) {
QTreeWidgetItem *b = new QTreeWidgetItem(this);
b->setText(0, QString("%1").arg(i));
b->setText(1, "some string");
}
}
void cSelectTree::Delete(void)
{
QTreeWidgetItem *Item = currentItem();
if (Item)
delete Item;
}
class cDialog : public QDialog {
public:
cDialog(QWidget *parent);
};
cDialog::cDialog(QWidget *parent)
{
QVBoxLayout *vbl = new QVBoxLayout(this);
cSelectTree *tree = new cSelectTree(this);
vbl->addWidget(tree);
QPushButton *b = new QPushButton("&Delete");
vbl->addWidget(b);
connect(b, SIGNAL(clicked(bool)), tree, SLOT(Delete(void)));
}
int main(int argc, char *argv[])
{
QApplication myapp(argc, argv);
cDialog *cd = new cDialog(NULL);
cd->show();
return myapp.exec();
}
#include "moc_treewidget-missing-focus-indicator.c"
Message 2 in thread
Klaus Schmidinger wrote:
> In my application I have a dialog with a QTreeWidget that allows the
> user to mark several items as selected, as well as deleting items
> via a "Delete" button. This all works nicely on Linux and Windows,
> but there is a problem on the Mac, because the user has no clue as
> to which item is the current one.
> ...
Are there really no Mac OS X users here?
Klaus Schmidinger
--
[ signature omitted ]
Message 3 in thread
On 4/4/07, Klaus Schmidinger <Klaus.Schmidinger@xxxxxxxxxx> wrote:
> Klaus Schmidinger wrote:
> > In my application I have a dialog with a QTreeWidget that allows the
> > user to mark several items as selected, as well as deleting items
> > via a "Delete" button. This all works nicely on Linux and Windows,
> > but there is a problem on the Mac, because the user has no clue as
> > to which item is the current one.
> > ...
>
> Are there really no Mac OS X users here?
Yes there is, but I never used QTreeWidget like this. Best thing for
Qt bugs is to send them to qt-bugs (at) trolltech.com
--
[ signature omitted ]
Message 4 in thread
Robin Ericsson wrote:
> On 4/4/07, Klaus Schmidinger <Klaus.Schmidinger@xxxxxxxxxx> wrote:
>> Klaus Schmidinger wrote:
>> > In my application I have a dialog with a QTreeWidget that allows the
>> > user to mark several items as selected, as well as deleting items
>> > via a "Delete" button. This all works nicely on Linux and Windows,
>> > but there is a problem on the Mac, because the user has no clue as
>> > to which item is the current one.
>> > ...
>>
>> Are there really no Mac OS X users here?
>
> Yes there is, but I never used QTreeWidget like this. Best thing for
> Qt bugs is to send them to qt-bugs (at) trolltech.com
I've already had a lengthy discussion about this with qt-bugs,
and they persistently refuse to do anything about this. They told
me to post this on qt-interest and possibly find others who also
see this as a problem.
Klaus Schmidinger
--
[ signature omitted ]
Message 5 in thread
I am not using 4.3 yet (and won't until later this year), but this sounds
like a big problem.
Keith
On 04-04-2007 6:40 AM, "Klaus Schmidinger" wrote:
> Robin Ericsson wrote:
>> On 4/4/07, Klaus Schmidinger <Klaus.Schmidinger@xxxxxxxxxx> wrote:
>>> Klaus Schmidinger wrote:
>>>> In my application I have a dialog with a QTreeWidget that allows the
>>>> user to mark several items as selected, as well as deleting items
>>>> via a "Delete" button. This all works nicely on Linux and Windows,
>>>> but there is a problem on the Mac, because the user has no clue as
>>>> to which item is the current one.
>>>> ...
>>>
>>> Are there really no Mac OS X users here?
>>
>> Yes there is, but I never used QTreeWidget like this. Best thing for
>> Qt bugs is to send them to qt-bugs (at) trolltech.com
>
> I've already had a lengthy discussion about this with qt-bugs,
> and they persistently refuse to do anything about this. They told
> me to post this on qt-interest and possibly find others who also
> see this as a problem.
>
> Klaus Schmidinger
--
[ signature omitted ]
Message 6 in thread
Hi,
> I've already had a lengthy discussion about this with qt-bugs,
> and they persistently refuse to do anything about this. They told
> me to post this on qt-interest and possibly find others who also
> see this as a problem.
They must be refusing to do anything about it because they don't see it
as a bug. If so, I guess they must have some argument (valid or not),
haven't they?
Since I don't have a Mac available right now, I'm afraid I have no clue
myself.
--
[ signature omitted ]