qwidget.sip 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. // qwidget.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. const int QWIDGETSIZE_MAX;
  22. class QWidget : public QObject, public QPaintDevice
  23. {
  24. %TypeHeaderCode
  25. #include <qwidget.h>
  26. %End
  27. %TypeCode
  28. // Transfer the ownership of a single widget to a parent.
  29. static void qtgui_TransferWidget(QWidget *w, PyObject *py_parent)
  30. {
  31. PyObject *py_w = sipGetPyObject(w, sipType_QWidget);
  32. if (py_w)
  33. sipTransferTo(py_w, py_parent);
  34. }
  35. // Transfer ownership of all widgets in a layout to their new parent.
  36. static void qtwidgets_TransferLayoutWidgets(QLayout *lay, PyObject *pw)
  37. {
  38. int n = lay->count();
  39. for (int i = 0; i < n; ++i)
  40. {
  41. QLayoutItem *item = lay->itemAt(i);
  42. QWidget *w = item->widget();
  43. if (w)
  44. {
  45. qtgui_TransferWidget(w, pw);
  46. }
  47. else
  48. {
  49. QLayout *l = item->layout();
  50. if (l)
  51. qtwidgets_TransferLayoutWidgets(l, pw);
  52. }
  53. }
  54. QWidget *mb = lay->menuBar();
  55. if (mb)
  56. qtgui_TransferWidget(mb, pw);
  57. }
  58. %End
  59. public:
  60. QWidget(QWidget *parent /TransferThis/ = 0, Qt::WindowFlags flags = Qt::WindowFlags());
  61. virtual ~QWidget();
  62. virtual int devType() const;
  63. QStyle *style() const;
  64. void setStyle(QStyle * /KeepReference/);
  65. bool isEnabledTo(const QWidget *) const;
  66. public slots:
  67. void setEnabled(bool);
  68. void setDisabled(bool);
  69. void setWindowModified(bool);
  70. public:
  71. QRect frameGeometry() const;
  72. QRect normalGeometry() const;
  73. int x() const;
  74. int y() const;
  75. QPoint pos() const;
  76. QSize frameSize() const;
  77. QRect childrenRect() const;
  78. QRegion childrenRegion() const;
  79. QSize minimumSize() const;
  80. QSize maximumSize() const;
  81. void setMinimumSize(int minw, int minh);
  82. void setMaximumSize(int maxw, int maxh);
  83. void setMinimumWidth(int minw);
  84. void setMinimumHeight(int minh);
  85. void setMaximumWidth(int maxw);
  86. void setMaximumHeight(int maxh);
  87. QSize sizeIncrement() const;
  88. void setSizeIncrement(int w, int h);
  89. QSize baseSize() const;
  90. void setBaseSize(int basew, int baseh);
  91. void setFixedSize(const QSize &);
  92. void setFixedSize(int w, int h);
  93. void setFixedWidth(int w);
  94. void setFixedHeight(int h);
  95. QPoint mapToGlobal(const QPoint &) const;
  96. QPointF mapToGlobal(const QPointF &) const;
  97. QPoint mapFromGlobal(const QPoint &) const;
  98. QPointF mapFromGlobal(const QPointF &) const;
  99. QPoint mapToParent(const QPoint &) const;
  100. QPointF mapToParent(const QPointF &) const;
  101. QPoint mapFromParent(const QPoint &) const;
  102. QPointF mapFromParent(const QPointF &) const;
  103. QPoint mapTo(const QWidget *, const QPoint &) const;
  104. QPointF mapTo(const QWidget *, const QPointF &) const;
  105. QPoint mapFrom(const QWidget *, const QPoint &) const;
  106. QPointF mapFrom(const QWidget *, const QPointF &) const;
  107. QWidget *window() const;
  108. const QPalette &palette() const;
  109. void setPalette(const QPalette &);
  110. void setBackgroundRole(QPalette::ColorRole);
  111. QPalette::ColorRole backgroundRole() const;
  112. void setForegroundRole(QPalette::ColorRole);
  113. QPalette::ColorRole foregroundRole() const;
  114. void setFont(const QFont &);
  115. QCursor cursor() const;
  116. void setCursor(const QCursor &);
  117. void unsetCursor();
  118. void setMask(const QBitmap &);
  119. void setMask(const QRegion &);
  120. QRegion mask() const;
  121. void clearMask();
  122. void setWindowTitle(const QString &);
  123. QString windowTitle() const;
  124. void setWindowIcon(const QIcon &icon);
  125. QIcon windowIcon() const;
  126. void setWindowIconText(const QString &);
  127. QString windowIconText() const;
  128. void setWindowRole(const QString &);
  129. QString windowRole() const;
  130. void setWindowOpacity(qreal level);
  131. qreal windowOpacity() const;
  132. bool isWindowModified() const;
  133. void setToolTip(const QString &);
  134. QString toolTip() const;
  135. void setStatusTip(const QString &);
  136. QString statusTip() const;
  137. void setWhatsThis(const QString &);
  138. QString whatsThis() const;
  139. %If (PyQt_Accessibility)
  140. QString accessibleName() const;
  141. %End
  142. %If (PyQt_Accessibility)
  143. void setAccessibleName(const QString &name);
  144. %End
  145. %If (PyQt_Accessibility)
  146. QString accessibleDescription() const;
  147. %End
  148. %If (PyQt_Accessibility)
  149. void setAccessibleDescription(const QString &description);
  150. %End
  151. void setLayoutDirection(Qt::LayoutDirection direction);
  152. Qt::LayoutDirection layoutDirection() const;
  153. void unsetLayoutDirection();
  154. bool isRightToLeft() const;
  155. bool isLeftToRight() const;
  156. public slots:
  157. void setFocus();
  158. public:
  159. bool isActiveWindow() const;
  160. void activateWindow();
  161. void clearFocus();
  162. void setFocus(Qt::FocusReason reason);
  163. Qt::FocusPolicy focusPolicy() const;
  164. void setFocusPolicy(Qt::FocusPolicy policy);
  165. bool hasFocus() const;
  166. static void setTabOrder(QWidget *, QWidget *);
  167. void setFocusProxy(QWidget * /KeepReference/);
  168. QWidget *focusProxy() const;
  169. Qt::ContextMenuPolicy contextMenuPolicy() const;
  170. void setContextMenuPolicy(Qt::ContextMenuPolicy policy);
  171. void grabMouse();
  172. void grabMouse(const QCursor &);
  173. void releaseMouse();
  174. void grabKeyboard();
  175. void releaseKeyboard();
  176. int grabShortcut(const QKeySequence &key, Qt::ShortcutContext context = Qt::WindowShortcut);
  177. void releaseShortcut(int id);
  178. void setShortcutEnabled(int id, bool enabled = true);
  179. static QWidget *mouseGrabber();
  180. static QWidget *keyboardGrabber();
  181. void setUpdatesEnabled(bool enable);
  182. public slots:
  183. void update();
  184. void repaint();
  185. public:
  186. void update(const QRect &);
  187. void update(const QRegion &);
  188. void repaint(int x, int y, int w, int h);
  189. void repaint(const QRect &);
  190. void repaint(const QRegion &);
  191. public slots:
  192. virtual void setVisible(bool visible);
  193. void setHidden(bool hidden);
  194. void show();
  195. void hide();
  196. void showMinimized();
  197. void showMaximized();
  198. void showFullScreen();
  199. void showNormal();
  200. bool close();
  201. void raise();
  202. void lower();
  203. public:
  204. void stackUnder(QWidget *);
  205. void move(const QPoint &);
  206. void resize(const QSize &);
  207. void setGeometry(const QRect &);
  208. void adjustSize();
  209. bool isVisibleTo(const QWidget *) const;
  210. bool isMinimized() const;
  211. bool isMaximized() const;
  212. bool isFullScreen() const;
  213. Qt::WindowStates windowState() const;
  214. void setWindowState(Qt::WindowStates state);
  215. void overrideWindowState(Qt::WindowStates state);
  216. virtual QSize sizeHint() const;
  217. virtual QSize minimumSizeHint() const;
  218. QSizePolicy sizePolicy() const;
  219. void setSizePolicy(QSizePolicy);
  220. virtual int heightForWidth(int) const;
  221. QRegion visibleRegion() const;
  222. void setContentsMargins(int left, int top, int right, int bottom);
  223. QRect contentsRect() const;
  224. QLayout *layout() const;
  225. void setLayout(QLayout * /Transfer/);
  226. %MethodCode
  227. Py_BEGIN_ALLOW_THREADS
  228. sipCpp->setLayout(a0);
  229. Py_END_ALLOW_THREADS
  230. // Internally Qt has reparented all of the widgets in the layout, so we need
  231. // to update the ownership hierachy.
  232. qtwidgets_TransferLayoutWidgets(a0, sipSelf);
  233. %End
  234. void updateGeometry();
  235. void setParent(QWidget *parent /TransferThis/);
  236. void setParent(QWidget *parent /TransferThis/, Qt::WindowFlags f);
  237. void scroll(int dx, int dy);
  238. void scroll(int dx, int dy, const QRect &);
  239. QWidget *focusWidget() const;
  240. QWidget *nextInFocusChain() const;
  241. bool acceptDrops() const;
  242. void setAcceptDrops(bool on);
  243. %If (Qt_6_3_0 -)
  244. QAction *addAction(const QIcon &icon, const QString &text) /Transfer/;
  245. %End
  246. %If (Qt_6_3_0 -)
  247. QAction *addAction(const QIcon &icon, const QString &text, SIP_PYOBJECT slot /TypeHint="PYQT_SLOT"/, Qt::ConnectionType type = Qt::AutoConnection) /Transfer/;
  248. %MethodCode
  249. QObject *receiver;
  250. QByteArray slot_signature;
  251. if ((sipError = pyqt6_qtwidgets_get_connection_parts(a2, sipCpp, "()", false, &receiver, slot_signature)) == sipErrorNone)
  252. {
  253. sipRes = sipCpp->addAction(*a0, *a1, receiver, slot_signature.constData(), a3);
  254. }
  255. else if (sipError == sipErrorContinue)
  256. {
  257. sipError = sipBadCallableArg(2, a2);
  258. }
  259. %End
  260. %End
  261. %If (Qt_6_3_0 -)
  262. QAction *addAction(const QIcon &icon, const QString &text, const QKeySequence &shortcut) /Transfer/;
  263. %End
  264. %If (Qt_6_3_0 -)
  265. QAction *addAction(const QIcon &icon, const QString &text, const QKeySequence &shortcut, SIP_PYOBJECT slot /TypeHint="PYQT_SLOT"/, Qt::ConnectionType type = Qt::AutoConnection) /Transfer/;
  266. %MethodCode
  267. QObject *receiver;
  268. QByteArray slot_signature;
  269. if ((sipError = pyqt6_qtwidgets_get_connection_parts(a3, sipCpp, "()", false, &receiver, slot_signature)) == sipErrorNone)
  270. {
  271. sipRes = sipCpp->addAction(*a0, *a1, *a2, receiver, slot_signature.constData(), a4);
  272. }
  273. else if (sipError == sipErrorContinue)
  274. {
  275. sipError = sipBadCallableArg(3, a3);
  276. }
  277. %End
  278. %End
  279. %If (Qt_6_3_0 -)
  280. QAction *addAction(const QString &text) /Transfer/;
  281. %End
  282. %If (Qt_6_3_0 -)
  283. QAction *addAction(const QString &text, const QKeySequence &shortcut) /Transfer/;
  284. %End
  285. %If (Qt_6_3_0 -)
  286. QAction *addAction(QString &text, SIP_PYOBJECT slot /TypeHint="PYQT_SLOT"/, Qt::ConnectionType type = Qt::AutoConnection) /Transfer/;
  287. %MethodCode
  288. QObject *receiver;
  289. QByteArray slot_signature;
  290. if ((sipError = pyqt6_qtwidgets_get_connection_parts(a1, sipCpp, "()", false, &receiver, slot_signature)) == sipErrorNone)
  291. {
  292. sipRes = sipCpp->addAction(*a0, receiver, slot_signature.constData(), a2);
  293. }
  294. else if (sipError == sipErrorContinue)
  295. {
  296. sipError = sipBadCallableArg(1, a1);
  297. }
  298. %End
  299. %End
  300. %If (Qt_6_3_0 -)
  301. QAction *addAction(const QString &text, const QKeySequence &shortcut, SIP_PYOBJECT slot /TypeHint="PYQT_SLOT"/, Qt::ConnectionType type = Qt::AutoConnection) /Transfer/;
  302. %MethodCode
  303. QObject *receiver;
  304. QByteArray slot_signature;
  305. if ((sipError = pyqt6_qtwidgets_get_connection_parts(a2, sipCpp, "()", false, &receiver, slot_signature)) == sipErrorNone)
  306. {
  307. sipRes = sipCpp->addAction(*a0, *a1, receiver, slot_signature.constData(), a3);
  308. }
  309. else if (sipError == sipErrorContinue)
  310. {
  311. sipError = sipBadCallableArg(2, a2);
  312. }
  313. %End
  314. %End
  315. void addAction(QAction *action);
  316. void addActions(const QList<QAction *> &actions);
  317. void insertAction(QAction *before, QAction *action);
  318. void insertActions(QAction *before, const QList<QAction *> &actions);
  319. void removeAction(QAction *action);
  320. QList<QAction *> actions() const;
  321. void setWindowFlags(Qt::WindowFlags type);
  322. void overrideWindowFlags(Qt::WindowFlags type);
  323. static QWidget *find(WId);
  324. QWidget *childAt(const QPoint &p) const;
  325. %If (Qt_6_8_0 -)
  326. QWidget *childAt(const QPointF &p) const;
  327. %End
  328. void setAttribute(Qt::WidgetAttribute attribute, bool on = true);
  329. virtual QPaintEngine *paintEngine() const;
  330. void ensurePolished() const;
  331. bool isAncestorOf(const QWidget *child) const;
  332. signals:
  333. void customContextMenuRequested(const QPoint &pos);
  334. protected:
  335. virtual bool event(QEvent *);
  336. virtual void mousePressEvent(QMouseEvent *);
  337. virtual void mouseReleaseEvent(QMouseEvent *);
  338. virtual void mouseDoubleClickEvent(QMouseEvent *);
  339. virtual void mouseMoveEvent(QMouseEvent *);
  340. virtual void wheelEvent(QWheelEvent *);
  341. virtual void keyPressEvent(QKeyEvent *);
  342. virtual void keyReleaseEvent(QKeyEvent *);
  343. virtual void focusInEvent(QFocusEvent *);
  344. virtual void focusOutEvent(QFocusEvent *);
  345. virtual void enterEvent(QEnterEvent *event);
  346. virtual void leaveEvent(QEvent *);
  347. virtual void paintEvent(QPaintEvent *);
  348. virtual void moveEvent(QMoveEvent *);
  349. virtual void resizeEvent(QResizeEvent *);
  350. virtual void closeEvent(QCloseEvent *);
  351. virtual void contextMenuEvent(QContextMenuEvent *);
  352. virtual void tabletEvent(QTabletEvent *);
  353. virtual void actionEvent(QActionEvent *);
  354. virtual void dragEnterEvent(QDragEnterEvent *);
  355. virtual void dragMoveEvent(QDragMoveEvent *);
  356. virtual void dragLeaveEvent(QDragLeaveEvent *);
  357. virtual void dropEvent(QDropEvent *);
  358. virtual void showEvent(QShowEvent *);
  359. virtual void hideEvent(QHideEvent *);
  360. virtual void changeEvent(QEvent *);
  361. virtual int metric(QPaintDevice::PaintDeviceMetric) const;
  362. virtual void inputMethodEvent(QInputMethodEvent *);
  363. public:
  364. virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const;
  365. protected:
  366. void updateMicroFocus(Qt::InputMethodQuery query = Qt::ImQueryAll);
  367. void create(WId window = 0, bool initializeWindow = true, bool destroyOldWindow = true);
  368. void destroy(bool destroyWindow = true, bool destroySubWindows = true);
  369. virtual bool focusNextPrevChild(bool next);
  370. bool focusNextChild();
  371. bool focusPreviousChild();
  372. public:
  373. QWidget *childAt(int ax, int ay) const;
  374. Qt::WindowType windowType() const;
  375. Qt::WindowFlags windowFlags() const;
  376. WId winId() const;
  377. bool isWindow() const;
  378. bool isEnabled() const;
  379. bool isModal() const;
  380. int minimumWidth() const;
  381. int minimumHeight() const;
  382. int maximumWidth() const;
  383. int maximumHeight() const;
  384. void setMinimumSize(const QSize &s);
  385. void setMaximumSize(const QSize &s);
  386. void setSizeIncrement(const QSize &s);
  387. void setBaseSize(const QSize &s);
  388. const QFont &font() const;
  389. QFontMetrics fontMetrics() const;
  390. QFontInfo fontInfo() const;
  391. void setMouseTracking(bool enable);
  392. bool hasMouseTracking() const;
  393. bool underMouse() const;
  394. bool updatesEnabled() const;
  395. void update(int ax, int ay, int aw, int ah);
  396. bool isVisible() const;
  397. bool isHidden() const;
  398. void move(int ax, int ay);
  399. void resize(int w, int h);
  400. void setGeometry(int ax, int ay, int aw, int ah);
  401. QRect rect() const;
  402. const QRect &geometry() const;
  403. QSize size() const;
  404. int width() const;
  405. int height() const;
  406. QWidget *parentWidget() const;
  407. void setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver);
  408. bool testAttribute(Qt::WidgetAttribute attribute) const;
  409. Qt::WindowModality windowModality() const;
  410. void setWindowModality(Qt::WindowModality windowModality);
  411. bool autoFillBackground() const;
  412. void setAutoFillBackground(bool enabled);
  413. void setStyleSheet(const QString &styleSheet);
  414. QString styleSheet() const;
  415. void setShortcutAutoRepeat(int id, bool enabled = true);
  416. QByteArray saveGeometry() const;
  417. bool restoreGeometry(const QByteArray &geometry);
  418. enum RenderFlag /BaseType=Flag/
  419. {
  420. DrawWindowBackground,
  421. DrawChildren,
  422. IgnoreMask,
  423. };
  424. typedef QFlags<QWidget::RenderFlag> RenderFlags;
  425. void render(QPaintDevice *target, const QPoint &targetOffset = QPoint(), const QRegion &sourceRegion = QRegion(), QWidget::RenderFlags flags = QWidget::RenderFlags(QWidget::DrawWindowBackground | QWidget::DrawChildren));
  426. void render(QPainter *painter, const QPoint &targetOffset = QPoint(), const QRegion &sourceRegion = QRegion(), QWidget::RenderFlags flags = QWidget::RenderFlags(QWidget::DrawWindowBackground | QWidget::DrawChildren));
  427. void setLocale(const QLocale &locale);
  428. QLocale locale() const;
  429. void unsetLocale();
  430. WId effectiveWinId() const;
  431. QWidget *nativeParentWidget() const;
  432. void setWindowFilePath(const QString &filePath);
  433. QString windowFilePath() const;
  434. QGraphicsProxyWidget *graphicsProxyWidget() const;
  435. QGraphicsEffect *graphicsEffect() const;
  436. void setGraphicsEffect(QGraphicsEffect *effect /Transfer/);
  437. void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags());
  438. void ungrabGesture(Qt::GestureType type);
  439. void setContentsMargins(const QMargins &margins);
  440. QMargins contentsMargins() const;
  441. QWidget *previousInFocusChain() const;
  442. Qt::InputMethodHints inputMethodHints() const;
  443. void setInputMethodHints(Qt::InputMethodHints hints);
  444. virtual bool hasHeightForWidth() const;
  445. QPixmap grab(const QRect &rectangle = QRect(QPoint(0, 0), QSize(-1, -1)));
  446. static SIP_PYOBJECT createWindowContainer(QWindow *window /GetWrapper/, QWidget *parent /GetWrapper/ = 0, Qt::WindowFlags flags = Qt::WindowFlags()) /Factory,TypeHint="QWidget"/;
  447. %MethodCode
  448. // Ownersip issues are complicated so we handle them explicitly.
  449. QWidget *w = QWidget::createWindowContainer(a0, a1, *a2);
  450. sipRes = sipConvertFromNewType(w, sipType_QWidget, a1Wrapper);
  451. if (sipRes)
  452. sipTransferTo(a0Wrapper, sipRes);
  453. %End
  454. QWindow *windowHandle() const;
  455. protected:
  456. virtual bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result /Out/);
  457. virtual QPainter *sharedPainter() const;
  458. virtual void initPainter(QPainter *painter) const;
  459. public:
  460. void setToolTipDuration(int msec);
  461. int toolTipDuration() const;
  462. signals:
  463. void windowTitleChanged(const QString &title);
  464. void windowIconChanged(const QIcon &icon);
  465. void windowIconTextChanged(const QString &iconText);
  466. public:
  467. void setTabletTracking(bool enable);
  468. bool hasTabletTracking() const;
  469. void setWindowFlag(Qt::WindowType, bool on = true);
  470. QScreen *screen() const;
  471. void setScreen(QScreen *);
  472. %If (Qt_6_9_0 -)
  473. QString accessibleIdentifier() const;
  474. %End
  475. %If (Qt_6_9_0 -)
  476. void setAccessibleIdentifier(const QString &identifier);
  477. %End
  478. };