Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

Q3DragObject Class Reference
[Qt3Support module]

The Q3DragObject class encapsulates MIME-based data transfer. More...

#include <Q3DragObject>

This class is part of the Qt 3 support library. It is provided to keep old source code working. We strongly advise against using it in new code. See Porting to Qt 4 for more information.

Inherits QObject and QMimeSource.

Inherited by Q3IconDrag, Q3ImageDrag, Q3StoredDrag, and Q3TextDrag.

Public Types

  • enum DragMode { DragDefault, DragCopy, DragMove, DragLink, DragCopyOrMove }

Public Functions

  • 28 public functions inherited from QObject
  • 3 public functions inherited from QMimeSource

Static Public Members

  • 4 static public members inherited from QObject

Protected Functions

  • virtual bool drag ( DragMode mode )
  • 7 protected functions inherited from QObject

Additional Inherited Members


Detailed Description

The Q3DragObject class encapsulates MIME-based data transfer.

Q3DragObject is the base class for all data that needs to be transferred between and within applications, both for drag and drop and for the clipboard.

See the Drag and drop documentation for an overview of how to provide drag and drop in your application.

See the QClipboard documentation for an overview of how to provide cut and paste in your application.

The drag() function is used to start a drag operation. You can specify the DragMode in the call or use one of the convenience functions dragCopy(), dragMove(), or dragLink(). The drag source where the data originated is retrieved with source(). If the data was dropped on a widget within the application, target() will return a pointer to that widget. Specify the pixmap to display during the drag with setPixmap().


Member Type Documentation

enum Q3DragObject::DragMode

This enum describes the possible drag modes.

ConstantValueDescription
Q3DragObject::DragDefault0The mode is determined heuristically.
Q3DragObject::DragCopy1The data is copied.
Q3DragObject::DragMove2The data is moved.
Q3DragObject::DragLink3The data is linked.
Q3DragObject::DragCopyOrMove4The user chooses the mode by using the Shift key to switch from the default copy mode to move mode.


Member Function Documentation

Q3DragObject::Q3DragObject ( QWidget * dragSource = 0, const char * name = 0 )

Constructs a drag object called name with a parent dragSource.

Note that the drag object will be deleted when the dragSource is deleted.

Q3DragObject::~Q3DragObject ()   [virtual]

Destroys the drag object, canceling any drag and drop operation in which it is involved.

bool Q3DragObject::drag ()

Starts a drag operation using the contents of this object, using DragDefault mode.

The function returns true if the caller should delete the original copy of the dragged data (but see target()); otherwise returns false.

If the drag contains references to information (e.g. file names in a Q3UriDrag are references) then the return value should always be ignored, as the target is expected to directly manipulate the content referred to by the drag object. On X11 the return value should always be correct anyway, but on Windows this is not necessarily the case; e.g. the file manager starts a background process to move files, so the source must not delete the files!

Note that on Windows the drag operation will start a blocking modal event loop that will not dispatch any QTimers.

bool Q3DragObject::drag ( DragMode mode )   [virtual protected]

This is an overloaded member function, provided for convenience.

Starts a drag operation using the contents of this object.

At this point, the object becomes owned by Qt, not the application. You should not delete the drag object or anything it references. The actual transfer of data to the target application will be done during future event processing - after that time the drag object will be deleted.

Returns true if the dragged data was dragged as a move, indicating that the caller should remove the original source of the data (the drag object must continue to have a copy); otherwise returns false.

The mode specifies the drag mode (see Q3DragObject::DragMode.) Normally one of the simpler drag(), dragMove(), or dragCopy() functions would be used instead.

void Q3DragObject::dragCopy ()

Starts a drag operation using the contents of this object, using DragCopy mode. Be sure to read the constraints described in drag().

See also drag(), dragMove(), and dragLink().

void Q3DragObject::dragLink ()

Starts a drag operation using the contents of this object, using DragLink mode. Be sure to read the constraints described in drag().

See also drag(), dragCopy(), and dragMove().

bool Q3DragObject::dragMove ()

Starts a drag operation using the contents of this object, using DragMove mode. Be sure to read the constraints described in drag().

See also drag(), dragCopy(), and dragLink().

QPixmap Q3DragObject::pixmap () const

Returns the currently set pixmap, or a null pixmap if none is set.

See also setPixmap() and QPixmap::isNull().

QPoint Q3DragObject::pixmapHotSpot () const

Returns the currently set pixmap hotspot.

See also setPixmap().

void Q3DragObject::setPixmap ( QPixmap pm, const QPoint & hotspot )   [virtual]

Set the pixmap, pm, to display while dragging the object. The platform-specific implementation will use this where it can - so provide a small masked pixmap, and do not assume that the user will actually see it. For example, cursors on Windows 95 are of limited size.

The hotspot is the point on (or off) the pixmap that should be under the cursor as it is dragged. It is relative to the top-left pixel of the pixmap.

Warning: We have seen problems with drag cursors on different graphics hardware and driver software on Windows. Setting the graphics acceleration in the display settings down one tick solved the problems in all cases.

See also pixmap().

void Q3DragObject::setPixmap ( QPixmap pm )   [virtual]

This is an overloaded member function, provided for convenience.

Uses a hotspot that positions the pixmap below and to the right of the mouse pointer. This allows the user to clearly see the point on the window where they are dragging the data.

QWidget * Q3DragObject::source ()

Returns a pointer to the widget where this object originated (the drag source).

QWidget * Q3DragObject::target ()   [static]

After the drag completes, this function will return the QWidget which received the drop, or 0 if the data was dropped on another application.

This can be useful for detecting the case where drag and drop is to and from the same widget.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Labs au hasard

Logo

Le moteur de rendu OpenVG

Les Qt Labs sont les laboratoires des développeurs de Qt, où ils peuvent partager des impressions sur le framework, son utilisation, ce que pourrait être son futur. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.1
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web