返回介绍

QTextDrag Class

发布于 2019-10-04 15:03:21 字数 3526 浏览 932 评论 0 收藏 0

The QTextDrag class is a drag and drop object for transferring plain and Unicode text. More...

#include <qdragobject.h>

Inherits QDragObject.

List of all member functions.

Public Members

  • QTextDrag ( constQString&text, QWidget*dragSource = 0, constchar*name = 0 )
  • QTextDrag ( QWidget*dragSource = 0, constchar*name = 0 )
  • ~QTextDrag ()
  • virtual void setText ( constQString&text )
  • virtual void setSubtype ( constQCString&st )

Static Public Members

  • bool canDecode ( constQMimeSource*e )
  • bool decode ( constQMimeSource*e, QString&str )
  • bool decode ( constQMimeSource*e, QString&str, QCString&subtype )

Detailed Description

The QTextDrag class is a drag and drop object for transferring plain and Unicode text.

Plain text is passed in a QString which may contain multiple lines (i.e. may contain newline characters).

Qt provides no built-in mechanism for delivering only a single-line.

For more information about drag and drop, see the QDragObject class and the drag and drop documentation.

See also Drag And Drop Classes.


Member Function Documentation

QTextDrag::QTextDrag ( constQString&text, QWidget*dragSource = 0, constchar*name = 0 )

Constructs a text drag object and sets its data to text. dragSource must be the drag source; name is the object name.

QTextDrag::QTextDrag ( QWidget*dragSource = 0, constchar*name = 0 )

Constructs a default text drag object. dragSource must be the drag source; name is the object name.

QTextDrag::~QTextDrag ()

Destroys the text drag object and frees up all allocated resources.

bool QTextDrag::canDecode ( constQMimeSource*e ) [static]

Returns TRUE if the information in e can be decoded into a QString; otherwise returns FALSE.

See also decode().

Example: iconview/simple_dd/main.cpp.

bool QTextDrag::decode ( constQMimeSource*e, QString&str ) [static]

Attempts to decode the dropped information in e into str. Returns TRUE if successful; otherwise returns FALSE.

See also canDecode().

Example: iconview/simple_dd/main.cpp.

bool QTextDrag::decode ( constQMimeSource*e, QString&str, QCString&subtype ) [static]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Attempts to decode the dropped information in e into str. Returns TRUE if successful; otherwise returns FALSE. If subtype is null, any text subtype is accepted; otherwise only the specified subtype is accepted.

See also canDecode().

void QTextDrag::setSubtype ( constQCString&st ) [virtual]

Sets the MIME subtype of the text being dragged to st. The default subtype is "plain", so the default MIME type of the text is "text/plain". You might use this to declare that the text is "text/html" by calling setSubtype("html").

void QTextDrag::setText ( constQString&text ) [virtual]

Sets the text to be dragged to text. You will need to call this if you did not pass the text during construction.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文