Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# Compatibility Members for QWidget

The following class members are part of the Qt 3 compatibility layer. They are provided to help you port old code to Qt 4. We strongly advise against using them in new code.

QWidget class reference

### Public Types

- enum BackgroundOrigin { WidgetOrigin, ParentOrigin, WindowOrigin, AncestorOrigin }

### Public Functions

- Qt::BackgroundMode backgroundMode () const
- QString caption () const
- QWidget * childAt ( int x, int y, bool includeThis ) const
- QWidget * childAt ( const QPoint & p, bool includeThis ) const
- bool close ( bool alsoDelete )
- QColorGroup colorGroup () const
- void constPolish () const
- void drawText ( const QPoint & p, const QString & s )
- void drawText ( int x, int y, const QString & s )
- void erase ()
- void erase ( int x, int y, int w, int h )
- void erase ( const QRect & rect )
- void erase ( const QRegion & rgn )
- bool hasMouse () const
- const QPixmap * icon () const
- QString iconText () const
- void iconify ()
- bool isInputMethodEnabled () const
- bool isVisibleToTLW () const
- bool ownCursor () const
- bool ownFont () const
- bool ownPalette () const
- QWidget * parentWidget ( bool sameWindow ) const
- void polish ()
- void recreate ( QWidget * parent, Qt::WFlags f, const QPoint & p, bool showIt = false )
- void repaint ( bool b )
- void repaint ( int x, int y, int w, int h, bool b )
- void repaint ( const QRect & r, bool b )
- void repaint ( const QRegion & rgn, bool b )
- void reparent ( QWidget * parent, Qt::WFlags f, const QPoint & p, bool showIt = false )
- void reparent ( QWidget * parent, const QPoint & p, bool showIt = false )
- void setBackgroundColor ( const QColor & color )
- void setBackgroundMode ( Qt::BackgroundMode widgetBackground, Qt::BackgroundMode paletteBackground = Qt::PaletteBackground )
- void setBackgroundPixmap ( const QPixmap & pixmap )
- void setCaption ( const QString & c )
- void setEraseColor ( const QColor & color )
- void setErasePixmap ( const QPixmap & pixmap )
- void setIcon ( const QPixmap & i )
- void setIconText ( const QString & it )
- void setInputMethodEnabled ( bool b )
- void setKeyCompression ( bool b )
- void setPaletteBackgroundColor ( const QColor & color )
- void setPaletteBackgroundPixmap ( const QPixmap & pixmap )
- void setPaletteForegroundColor ( const QColor & color )
- void unsetFont ()
- void unsetPalette ()
- QRect visibleRect () const

## Member Type Documentation

### enum QWidget::BackgroundOrigin

`QWidget::WidgetOrigin` |
`QWidget::ParentOrigin` |
`QWidget::WindowOrigin` |
`QWidget::AncestorOrigin` |

## Member Function Documentation

### Qt::BackgroundMode QWidget::backgroundMode () const

Returns the color role used for painting the widget's background.

Use QPalette(backgroundRole(()) instead.

### QString QWidget::caption () const

Use windowTitle() instead.

### QWidget * QWidget::childAt ( int x, int y, bool includeThis ) const

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

Use the two coordinate argument overload instead.

### QWidget * QWidget::childAt ( const QPoint & p, bool includeThis ) const

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

Use the single point argument overload instead.

### bool QWidget::close ( bool alsoDelete )

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

Closes the widget.

Use the no-argument overload instead.

### QColorGroup QWidget::colorGroup () const

Use QColorGroup(palette()) instead.

### void QWidget::constPolish () const

Use ensurePolished() instead.

### void QWidget::drawText ( const QPoint & p, const QString & s )

Drawing may only take place in a QPaintEvent. Overload paintEvent() to do your drawing and call update() to schedule a replaint whenever necessary. See also QPainter.

### void QWidget::drawText ( int x, int y, const QString & s )

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

Drawing may only take place in a QPaintEvent. Overload paintEvent() to do your drawing and call update() to schedule a replaint whenever necessary. See also QPainter.

### void QWidget::erase ()

Drawing may only take place in a QPaintEvent. Overload paintEvent() to do your erasing and call update() to schedule a replaint whenever necessary. See also QPainter.

### void QWidget::erase ( int x, int y, int w, int h )

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

Drawing may only take place in a QPaintEvent. Overload paintEvent() to do your erasing and call update() to schedule a replaint whenever necessary. See also QPainter.

### void QWidget::erase ( const QRect & rect )

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

Drawing may only take place in a QPaintEvent. Overload paintEvent() to do your erasing and call update() to schedule a replaint whenever necessary. See also QPainter.

### void QWidget::erase ( const QRegion & rgn )

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

Clear the given region, rgn.

Drawing may only take place in a QPaintEvent. Overload paintEvent() to do your erasing and call update() to schedule a replaint whenever necessary. See also QPainter.

### bool QWidget::hasMouse () const

Use testAttribute(Qt::WA_UnderMouse) instead.

### const QPixmap * QWidget::icon () const

Return's the widget's icon.

Use windowIconText() instead().

### QString QWidget::iconText () const

Use windowIconText() instead();

### void QWidget::iconify ()

Use showMinimized() instead.

### bool QWidget::isInputMethodEnabled () const

### bool QWidget::isVisibleToTLW () const

Use isVisible() instead.

### bool QWidget::ownCursor () const

Use testAttribute(Qt::WA_SetCursor) instead.

### bool QWidget::ownFont () const

Use testAttribute(Qt::WA_SetFont) instead.

### bool QWidget::ownPalette () const

Use testAttribute(Qt::WA_SetPalette) instead.

### QWidget * QWidget::parentWidget ( bool sameWindow ) const

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

Use the no-argument overload instead.

### void QWidget::polish ()

### void QWidget::recreate ( QWidget * parent, Qt::WFlags f, const QPoint & p, bool showIt = false )

Use setParent() to change the parent or the widget's widget flags; use move() to move the widget, and use show() to show the widget.

### void QWidget::repaint ( bool b )

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

Use the no-argument overload instead.

### void QWidget::repaint ( int x, int y, int w, int h, bool b )

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

Use the four-argument overload instead.

### void QWidget::repaint ( const QRect & r, bool b )

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

Use the single rect-argument overload instead.

### void QWidget::repaint ( const QRegion & rgn, bool b )

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

Use the single region-argument overload instead.

### void QWidget::reparent ( QWidget * parent, Qt::WFlags f, const QPoint & p, bool showIt = false )

Use setParent() to change the parent or the widget's widget flags; use move() to move the widget, and use show() to show the widget.

### void QWidget::reparent ( QWidget * parent, const QPoint & p, bool showIt = false )

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

Use setParent() to change the parent; use move() to move the widget, and use show() to show the widget.

### void QWidget::setBackgroundColor ( const QColor & color )

Use the palette instead.

For example, if you have code like

        widget->setBackgroundColor(color);

you can rewrite it as

        QPalette palette(widget->palette());
        palette.setColor(widget->backgroundRole(), color);
        widget->setPalette(palette);

### void QWidget::setBackgroundMode ( Qt::BackgroundMode widgetBackground, Qt::BackgroundMode paletteBackground = Qt::PaletteBackground )

Sets the color role used for painting the widget's background to background mode widgetBackground. The paletteBackground mode parameter is ignored.

### void QWidget::setBackgroundPixmap ( const QPixmap & pixmap )

Use the palette instead.

For example, if you have code like

        widget->setBackgroundPixmap(pixmap);

you can rewrite it as

        QPalette palette(widget->palette());
        palette.setBrush(widget->backgroundRole(), QBrush(pixmap));
        widget->setPalette(palette);

### void QWidget::setCaption ( const QString & c )

Use setWindowTitle() instead.

### void QWidget::setEraseColor ( const QColor & color )

Use the palette instead.

For example, if you have code like

        widget->setEraseColor(color);

you can rewrite it as

        QPalette palette(widget->palette());
        palette.setColor(widget->backgroundRole(), color);
        widget->setPalette(palette);

### void QWidget::setErasePixmap ( const QPixmap & pixmap )

Use the palette instead.

For example, if you have code like

        widget->setErasePixmap(pixmap);

you can rewrite it as

        QPalette palette(widget->palette());
        palette.setBrush(widget->backgroundRole(), QBrush(pixmap));
        widget->setPalette(palette);

### void QWidget::setIcon ( const QPixmap & i )

Use setWindowIcon() instead.

### void QWidget::setIconText ( const QString & it )

Use setWindowIconText() instead.

### void QWidget::setInputMethodEnabled ( bool b )

### void QWidget::setKeyCompression ( bool b )

Use setAttribute(Qt::WA_KeyCompression, b) instead.

### void QWidget::setPaletteBackgroundColor ( const QColor & color )

Use the palette directly.

For example, if you have code like

        widget->setPaletteBackgroundColor(color);

you can rewrite it as

        QPalette palette(widget->palette());
        palette.setColor(widget->backgroundRole(), color);
        widget->setPalette(palette);

### void QWidget::setPaletteBackgroundPixmap ( const QPixmap & pixmap )

Use the palette directly.

For example, if you have code like

        widget->setPaletteBackgroundPixmap(pixmap);

you can rewrite it as

        QPalette palette(widget->palette());
        palette.setBrush(widget->backgroundRole(), QBrush(pixmap));
        widget->setPalette(palette);

### void QWidget::setPaletteForegroundColor ( const QColor & color )

Use the palette directly.

For example, if you have code like

        widget->setPaletteForegroundColor(color);

you can rewrite it as

        QPalette palette(widget->palette());
        palette.setColor(widget->foregroundRole(), color);
        widget->setPalette(palette);

### void QWidget::unsetFont ()

Use setFont(QFont()) instead.

### void QWidget::unsetPalette ()

Use setPalette(QPalette()) instead.

### QRect QWidget::visibleRect () const

holds the widget's visible rectangle