[Qt-interest] Displaying the File menu for Draged TreeWidget items
Yuvaraj R
yuvaraj at ongobiz.com
Tue Jul 28 09:36:47 CEST 2009
Ok.
I have overrdding the QtreeWidget as follows
#include "treewidget_override.h"
TreeWidget_Override::TreeWidget_Override(QWidget *parent)
: QTreeWidget(parent)
{
}
bool TreeWidget_Override::dropMimeData(QTreeWidgetItem *parent, int index,
const
QMimeData *data, Qt::DropAction action)
{
for( int i =0; i< this->topLevelItemCount();i++)
{
if (parent== this->topLevelItem(i)) //check accepting item is parent or not.
{
QByteArray text = data->data("foo/bar");
QDataStream ds(&text, QIODevice::ReadOnly);
while (!ds.atEnd()) {
QString str;
ds >> str;
for(int j=0; j<this->topLevelItem(i)->childCount();j++)
{
if(str ==this->topLevelItem(i)->child(j)->text(0))
{
return 0;
}
}
QTreeWidgetItem *newItem = new QTreeWidgetItem(parent);
newItem->setText(0, str);
}
}
}
}
QStringList TreeWidget_Override::mimeTypes () const
{
QStringList qstrList;
qstrList.append("foo/bar");
return qstrList;
}
Qt::DropActions TreeWidget_Override::supportedDropActions () const
{
return Qt::CopyAction | Qt::MoveAction;
}
QMimeData *TreeWidget_Override::mimeData(const QList<QTreeWidgetItem *>
items) const
{
QByteArray text;
QDataStream ds(&text, QIODevice::WriteOnly);
for (int i=0;i<items.size();i++)
ds << items.at(i)->text(0);
QMimeData *md = new QMimeData;
md->setData("foo/bar", text);
return md;
}
I had set conditon to show menu for Toplevelitem 1,it was showing..when i am
setting for dragged items ,it is not displaying the menu.
Any mistake have i done at above code ?
how i solve this issue..
Thanks
Yuvaraj R.
On Tue, Jul 28, 2009 at 12:48 PM, Thiago Macieira <
thiago.macieira at trolltech.com> wrote:
> Yuvaraj R wrote:
> >Hi All
> >
> >
> >Please Can anybody give me a solution for this issue.
>
> If someone knows the answer, they will post it. If they don't, you will
> get no solution.
>
> But you also depend on people's availability. Please don't repost
> questions less than a week after you first posted it. Wait at least a week.
>
> And if after a week you got no answer, do not simply repost. Maybe no one
> answered because no one understood, so you should rephrase your question
> and add more information. And in that week, you're supposed to try and
> solve it yourself again, so post what other things you've tried.
>
> Please read the Smart Questions article by Eric Raymond.
>
> --
> Thiago Macieira - thiago.macieira (AT) nokia.com
> Senior Product Manager - Nokia, Qt Software
> Sandakerveien 116, NO-0402 Oslo, Norway
>
> _______________________________________________
> 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/20090728/7afb50fe/attachment.html
More information about the Qt-interest-old
mailing list