Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
|
|
Source code |
1 2 3 |
setAcceptDrops(true); setDragSelect(true); viewport ()->setAcceptDrops(true); |
Quoted
U can make anything, but nothing can make U.
Quoted
void contentsDragEnterEvent(QDragEnterEvent *event);
void contentsDropEvent(QDropEvent *event);
Quoted
U can make anything, but nothing can make U.
This post has been edited 1 times, last edit by "Manivannan_1984" (Feb 27th 2007, 12:47pm)
Quoted
I didn't inherit QListbox directly to my class,
Quoted
if do I will get many errors..
How this can be solved..?
Quoted
U can make anything, but nothing can make U.
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
ProjectView::ProjectView(QWidget *parent, const char *name)
: QListBox(parent, name)
{
setAcceptDrops(true);
}
void ProjectView::mousePressEvent(QMouseEvent *a_event)
{
QListBox::mousePressEvent( a_event );
dragging = TRUE;
}
void ProjectView::mouseMoveEvent(QMouseEvent *a_event)
{
if ( dragging )
{
int distance = (a_event->pos() - dragPos).manhattanLength();
if (distance > QApplication::startDragDistance())
{
QDragObject *d = new QTextDrag( currentText(), this );
d->drag(); // do NOT delete d.
dragging = FALSE;
}
}
}
void ProjectView::dragEnterEvent(QDragEnterEvent *a_event)
{
if ( QTextDrag::canDecode( a_event ) )
{
a_event->accept();
}
}
void ProjectView::dropEvent(QDropEvent *a_event)
{
QString text;
if ( QTextDrag::decode( a_event, text ) )
insertItem( text );
}
|
Quoted
U can make anything, but nothing can make U.
This post has been edited 2 times, last edit by "Manivannan_1984" (Feb 28th 2007, 8:39am)
Quoted
U can make anything, but nothing can make U.