qlabel.sip 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. // qlabel.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtWidgets Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  8. //
  9. // This file may be used under the terms of the GNU General Public License
  10. // version 3.0 as published by the Free Software Foundation and appearing in
  11. // the file LICENSE included in the packaging of this file. Please review the
  12. // following information to ensure the GNU General Public License version 3.0
  13. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // If you do not wish to use this file under the terms of the GPL version 3.0
  16. // then you may purchase a commercial license. For more information contact
  17. // info@riverbankcomputing.com.
  18. //
  19. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. class QLabel : public QFrame
  22. {
  23. %TypeHeaderCode
  24. #include <qlabel.h>
  25. %End
  26. public:
  27. QLabel(QWidget *parent /TransferThis/ = 0, Qt::WindowFlags flags = Qt::WindowFlags());
  28. QLabel(const QString &text, QWidget *parent /TransferThis/ = 0, Qt::WindowFlags flags = Qt::WindowFlags());
  29. virtual ~QLabel();
  30. QString text() const;
  31. QPixmap pixmap() const;
  32. QPicture picture() const;
  33. QMovie *movie() const;
  34. Qt::TextFormat textFormat() const;
  35. void setTextFormat(Qt::TextFormat);
  36. Qt::Alignment alignment() const;
  37. void setAlignment(Qt::Alignment);
  38. void setWordWrap(bool on);
  39. bool wordWrap() const;
  40. int indent() const;
  41. void setIndent(int);
  42. int margin() const;
  43. void setMargin(int);
  44. bool hasScaledContents() const;
  45. void setScaledContents(bool);
  46. virtual QSize sizeHint() const;
  47. virtual QSize minimumSizeHint() const;
  48. void setBuddy(QWidget * /KeepReference/);
  49. QWidget *buddy() const;
  50. virtual int heightForWidth(int) const;
  51. bool openExternalLinks() const;
  52. void setTextInteractionFlags(Qt::TextInteractionFlags flags);
  53. Qt::TextInteractionFlags textInteractionFlags() const;
  54. void setOpenExternalLinks(bool open);
  55. public slots:
  56. void clear();
  57. void setMovie(QMovie *movie /KeepReference/);
  58. void setNum(double /Constrained/);
  59. void setNum(int);
  60. void setPicture(const QPicture &);
  61. void setPixmap(const QPixmap &);
  62. void setText(const QString &);
  63. signals:
  64. void linkActivated(const QString &link);
  65. void linkHovered(const QString &link);
  66. protected:
  67. virtual bool event(QEvent *e);
  68. virtual void paintEvent(QPaintEvent *);
  69. virtual void changeEvent(QEvent *);
  70. virtual void keyPressEvent(QKeyEvent *ev);
  71. virtual void mousePressEvent(QMouseEvent *ev);
  72. virtual void mouseMoveEvent(QMouseEvent *ev);
  73. virtual void mouseReleaseEvent(QMouseEvent *ev);
  74. virtual void contextMenuEvent(QContextMenuEvent *ev);
  75. virtual void focusInEvent(QFocusEvent *ev);
  76. virtual void focusOutEvent(QFocusEvent *ev);
  77. virtual bool focusNextPrevChild(bool next);
  78. public:
  79. void setSelection(int, int);
  80. bool hasSelectedText() const;
  81. QString selectedText() const;
  82. int selectionStart() const;
  83. %If (Qt_6_1_0 -)
  84. SIP_PYCALLABLE resourceProvider() const /TypeHint="Callable[[QUrl], QVariant]"/;
  85. %MethodCode
  86. if (sipCpp->resourceProvider())
  87. sipRes = sipGetUserObject((sipSimpleWrapper *)sipSelf);
  88. else
  89. sipRes = SIP_NULLPTR;
  90. if (!sipRes)
  91. sipRes = Py_None;
  92. Py_INCREF(sipRes);
  93. %End
  94. %End
  95. %If (Qt_6_1_0 -)
  96. void setResourceProvider(SIP_PYCALLABLE provider /TypeHint="Callable[[QUrl], QVariant]"/);
  97. %MethodCode
  98. // Remove any existing callable.
  99. Py_XDECREF(sipGetUserObject((sipSimpleWrapper *)sipSelf));
  100. if (a0 == Py_None)
  101. {
  102. sipSetUserObject((sipSimpleWrapper *)sipSelf, SIP_NULLPTR);
  103. sipCpp->setResourceProvider(SIP_NULLPTR);
  104. }
  105. else
  106. {
  107. // Save the callable so that resourceProvider() can return it.
  108. Py_INCREF(a0);
  109. sipSetUserObject((sipSimpleWrapper *)sipSelf, a0);
  110. Py_BEGIN_ALLOW_THREADS
  111. sipCpp->setResourceProvider([a0] (const QUrl &arg) {
  112. QUrl *arg_heap = new QUrl(arg);
  113. QVariant qv;
  114. int is_err = 1;
  115. SIP_BLOCK_THREADS
  116. PyObject *arg_obj = sipConvertFromNewType(arg_heap, sipType_QUrl, NULL);
  117. if (arg_obj)
  118. {
  119. PyObject *res_obj = PyObject_CallFunctionObjArgs(a0, arg_obj, NULL);
  120. Py_DECREF(arg_obj);
  121. if (res_obj)
  122. {
  123. is_err = 0;
  124. QVariant *res = reinterpret_cast<QVariant *>(
  125. sipConvertToType(res_obj, sipType_QVariant, NULL, 0,
  126. NULL, &is_err));
  127. if (!is_err)
  128. {
  129. qv = *res;
  130. delete res;
  131. }
  132. }
  133. }
  134. else
  135. {
  136. delete arg_heap;
  137. }
  138. if (is_err)
  139. {
  140. pyqt6_qtwidgets_err_print();
  141. }
  142. SIP_UNBLOCK_THREADS
  143. return qv;
  144. });
  145. Py_END_ALLOW_THREADS
  146. }
  147. %End
  148. %End
  149. };
  150. %ModuleHeaderCode
  151. // Imports from QtCore.
  152. typedef void (*pyqt6_qtwidgets_err_print_t)();
  153. extern pyqt6_qtwidgets_err_print_t pyqt6_qtwidgets_err_print;
  154. %End
  155. %ModuleCode
  156. // Imports from QtCore.
  157. pyqt6_qtwidgets_err_print_t pyqt6_qtwidgets_err_print;
  158. %End
  159. %PostInitialisationCode
  160. // Imports from QtCore.
  161. pyqt6_qtwidgets_err_print = (pyqt6_qtwidgets_err_print_t)sipImportSymbol("pyqt6_err_print");
  162. Q_ASSERT(pyqt6_qtwidgets_err_print);
  163. %End