Hello, sorry for taking so long to answer. First: Thank you for ur reply, that did the trick. However, since i have now programmed an underlying "unified" Data-Layer that keeps the Programm Data and the Data in the Database in sync i have gone to simply just use the ID's to identify the dragged Objects. That was a) simpler to write, b) it doesn't mess up my Data by creating new Objects when a reference to an already existing one would be enough.
But I'll most certainly need it in the next part of the Project, so thanks! Gunnar Sletta <[email protected]> schrieb am Tuesday 14 April 2009 um 08:18:07: > Philipp Schmidt wrote: > > Hi, > > > > I have the following Problem. While trying to get Drag&Drop working (only > > accepting items whose ID is not yet in the List) with the mime-type > > "application/x-qabstractitemmodeldatalist" i found that i can't get > > conversion between datastreams and items working. The following Listing > > gives me this result: > > > > 1 - test > > 0 - > > > > So what am I doing wrong? > > > > ---- Source ---- > > QListWidgetItem i = new QListWidgetItem("test", ui.geschwisterList, 1); > > QDataStream d = new QDataStream(); > > i.write(d); > > QListWidgetItem i2 = new QListWidgetItem(); > > i2.read(d); > > log.debug(i.type() +" - "+i.text()); > > log.debug(i2.type() +" - "+i2.text()); > > ------------------- > > Hi, > > Sorry for late reply. > > You are using a datastream without a device for both reading and writing > at the same time. Since there is no device the behaviour is more or less > undefined. Instead, use a QByteArray as the device and use a separate > datastream for reading and writing: > > import com.trolltech.qt.*; > import com.trolltech.qt.core.*; > import com.trolltech.qt.gui.*; > > public class datastream > { > public static void main(String args[]) { > QCoreApplication.initialize(args); > > QListWidgetItem i = new QListWidgetItem("test", null, 1); > > QByteArray array = new QByteArray(); > QDataStream writer = new QDataStream(array, > QIODevice.OpenModeFlag.WriteOnly); > i.write(writer); > > QListWidgetItem i2 = new QListWidgetItem(); > > QDataStream reader = new QDataStream(array, > QIODevice.OpenModeFlag.ReadOnly); > i2.read(reader); > > System.out.println(i.type() +" - "+i.text()); > System.out.println(i2.type() +" - "+i2.text()); > } > } > > > best regards, > Gunnar _______________________________________________ Qt-jambi-interest mailing list [email protected] http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest
