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