[Qt-interest] QStandardItemModel spread only with one click

David Boosalis david.boosalis at gmail.com
Sat Sep 25 06:37:21 CEST 2010


If your using a QTreeView (I think it will work for QTreeWidget.

You can capture the mouse event yourself test it and then emit a signal to
expand all.  Something like this:

void MyTreeView::mousePressEvent(QMouseEvent *me)
{
  QModelIndex index;
  if (me->button() == Qt::RightButton) {  // or use left mouse button if you
lie
    index = indexAt(me->pos());
    if (index.isValid()) {
      me->accept();
      emit itemClicked(index,me->globalPos());
   }
  else
    QTreeView::mousePressEvent(me);
}


MyParentWidget::itemPressedSlot(ModelIndex mi, QPoint pos)
{
  QStandardItem *item = myModel->itemFromIndex(mi);


}

On Tue, Sep 21, 2010 at 10:37 AM, Frank Lutz <frank422542 at googlemail.com>wrote:

> Hi,
>
> do there is a posability to modify the Model to click only one time at
> the item to spread the tree?
>
> Greetings
> frank
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100924/7663fa89/attachment.html 


More information about the Qt-interest-old mailing list