Source Code (Use browser search to find items of interest.)
Class Index
qt'QWidget (./qt-2.1.0/src/kernel/qwidget.h:48)
class Q_EXPORT QWidget : public QObject, public QPaintDevice
{
Q_OBJECT
Q_ENUMS( BackgroundMode PropagationMode FocusPolicy BackgroundOrigin )
Q_PROPERTY( bool isTopLevel READ isTopLevel )
Q_PROPERTY( bool isModal READ isModal )
Q_PROPERTY( bool isPopup READ isPopup )
Q_PROPERTY( bool isDesktop READ isDesktop )
Q_PROPERTY( bool enabled READ isEnabled WRITE setEnabled )
Q_PROPERTY( QRect geometry READ geometry WRITE setGeometry )
Q_PROPERTY( QRect frameGeometry READ frameGeometry )
Q_PROPERTY( int x READ x )
Q_PROPERTY( int y READ y )
Q_PROPERTY( QPoint pos READ pos )
Q_PROPERTY( QSize frameSize READ frameSize )
Q_PROPERTY( QSize size READ size WRITE resize DESIGNABLE false )
Q_PROPERTY( int width READ width )
Q_PROPERTY( int height READ height )
Q_PROPERTY( QRect rect READ rect )
Q_PROPERTY( QRect childrenRect READ childrenRect )
Q_PROPERTY( QRegion childrenRegion READ childrenRegion )
Q_PROPERTY( QSize minimumSize READ minimumSize WRITE setMinimumSize )
Q_PROPERTY( QSize maximumSize READ maximumSize WRITE setMaximumSize )
Q_PROPERTY( int minimumWidth READ minimumWidth WRITE setMinimumWidth STORED false )
Q_PROPERTY( int minimumHeight READ minimumHeight WRITE setMinimumHeight STORED false )
Q_PROPERTY( int maximumWidth READ maximumWidth WRITE setMaximumWidth STORED false )
Q_PROPERTY( int maximumHeight READ maximumHeight WRITE setMaximumHeight STORED false )
Q_PROPERTY( QSize sizeIncrement READ sizeIncrement WRITE setSizeIncrement )
Q_PROPERTY( QSize baseSize READ baseSize WRITE setBaseSize )
Q_PROPERTY( BackgroundMode backgroundMode READ backgroundMode WRITE setBackgroundMode DESIGNABLE false )
Q_PROPERTY( QColor backgroundColor READ backgroundColor WRITE setBackgroundColor DESIGNABLE false )
Q_PROPERTY( QColor foregroundColor READ foregroundColor )
Q_PROPERTY( QPixmap backgroundPixmap READ backgroundPixmap WRITE setBackgroundPixmap DESIGNABLE false )
Q_PROPERTY( QColorGroup colorGroup READ colorGroup )
Q_PROPERTY( QPalette palette READ palette WRITE setPalette RESET unsetPalette )
Q_PROPERTY( QFont font READ font WRITE setFont RESET unsetFont )
Q_PROPERTY( QCursor cursor READ cursor WRITE setCursor RESET unsetCursor )
Q_PROPERTY( QString caption READ caption WRITE setCaption )
Q_PROPERTY( QPixmap icon READ icon WRITE setIcon )
Q_PROPERTY( QString iconText READ iconText WRITE setIconText )
Q_PROPERTY( bool mouseTracking READ hasMouseTracking WRITE setMouseTracking )
Q_PROPERTY( bool isActiveWindow READ isActiveWindow )
Q_PROPERTY( bool focusEnabled READ isFocusEnabled )
Q_PROPERTY( FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy )
Q_PROPERTY( bool focus READ hasFocus )
Q_PROPERTY( bool updatesEnabled READ isUpdatesEnabled WRITE setUpdatesEnabled DESIGNABLE false )
Q_PROPERTY( bool visible READ isVisible )
Q_PROPERTY( bool visibleToTLW READ isVisibleToTLW )
Q_PROPERTY( QRect visibleRect READ visibleRect )
Q_PROPERTY( bool minimized READ isMinimized )
Q_PROPERTY( QSize sizeHint READ sizeHint )
Q_PROPERTY( QSize minimumSizeHint READ minimumSizeHint )
Q_PROPERTY( QRect microFocusHint READ microFocusHint )
Q_PROPERTY( bool acceptDrops READ acceptDrops WRITE setAcceptDrops )
Q_PROPERTY( bool autoMask READ autoMask WRITE setAutoMask )
Q_PROPERTY( BackgroundOrigin backgroundOrigin READ backgroundOrigin WRITE setBackgroundOrigin )
Q_PROPERTY( bool customWhatsThis READ customWhatsThis )
public:
QWidget( QWidget *parent=0, const char *name=0, WFlags f=0 );
~QWidget();
WId winId() const;
void setName( const char *name );
// GUI style setting
QStyle &style() const;
void setStyle( QStyle * );
// Widget types and states
bool isTopLevel() const;
bool isModal() const;
bool isPopup() const;
bool isDesktop() const;
bool isEnabled() const;
bool isEnabledTo(QWidget*) const;
bool isEnabledToTLW() const;
public slots:
virtual void setEnabled( bool );
// Widget coordinates
public:
QRect frameGeometry() const;
const QRect &geometry() const;
int x() const;
int y() const;
QPoint pos() const;
QSize frameSize() const;
QSize size() const;
int width() const;
int height() const;
QRect rect() const;
QRect childrenRect() const;
QRegion childrenRegion() const;
QSize minimumSize() const;
QSize maximumSize() const;
int minimumWidth() const;
int minimumHeight() const;
int maximumWidth() const;
int maximumHeight() const;
void setMinimumSize( const QSize & );
virtual void setMinimumSize( int minw, int minh );
void setMaximumSize( const QSize & );
virtual void setMaximumSize( int maxw, int maxh );
void setMinimumWidth( int minw );
void setMinimumHeight( int minh );
void setMaximumWidth( int maxw );
void setMaximumHeight( int maxh );
QSize sizeIncrement() const;
void setSizeIncrement( const QSize & );
virtual void setSizeIncrement( int w, int h );
QSize baseSize() const;
void setBaseSize( const QSize & );
void setBaseSize( int basew, int baseh );
void setFixedSize( const QSize & );
void setFixedSize( int w, int h );
void setFixedWidth( int w );
void setFixedHeight( int h );
// Widget coordinate mapping
QPoint mapToGlobal( const QPoint & ) const;
QPoint mapFromGlobal( const QPoint & ) const;
QPoint mapToParent( const QPoint & ) const;
QPoint mapFromParent( const QPoint & ) const;
QWidget *topLevelWidget() const;
// Widget attribute functions
enum BackgroundMode { FixedColor, FixedPixmap, NoBackground,
PaletteForeground, PaletteButton, PaletteLight,
PaletteMidlight, PaletteDark, PaletteMid,
PaletteText, PaletteBrightText, PaletteBase,
PaletteBackground, PaletteShadow, PaletteHighlight,
PaletteHighlightedText };
BackgroundMode backgroundMode() const;
virtual void setBackgroundMode( BackgroundMode );
const QColor & backgroundColor() const;
const QColor & foregroundColor() const;
virtual void setBackgroundColor( const QColor & );
const QPixmap * backgroundPixmap() const;
virtual void setBackgroundPixmap( const QPixmap & );
const QColorGroup & colorGroup() const;
const QPalette & palette() const;
virtual void setPalette( const QPalette & );
void unsetPalette();
QFont font() const;
virtual void setFont( const QFont & );
void unsetFont();
QFontMetrics fontMetrics() const;
QFontInfo fontInfo() const;
enum PropagationMode { NoChildren, AllChildren,
SameFont, SamePalette = SameFont };
PropagationMode fontPropagation() const; // obsolete, remove 3.0
virtual void setFontPropagation( PropagationMode ); // obsolete, remove 3.0
PropagationMode palettePropagation() const; // obsolete, remove 3.0
virtual void setPalettePropagation( PropagationMode ); // obsolete, remove 3.0
const QCursor &cursor() const;
virtual void setCursor( const QCursor & );
virtual void unsetCursor();
QString caption() const;
const QPixmap *icon() const;
QString iconText() const;
bool hasMouseTracking() const;
virtual void setMask( const QBitmap & );
virtual void setMask( const QRegion & );
void clearMask();
public slots:
virtual void setCaption( const QString &);
virtual void setIcon( const QPixmap & );
virtual void setIconText( const QString &);
virtual void setMouseTracking( bool enable );
// Keyboard input focus functions
virtual void setFocus();
void clearFocus();
public:
enum FocusPolicy {
NoFocus = 0,
TabFocus = 0x1,
ClickFocus = 0x2,
StrongFocus = 0x3,
WheelFocus = 0x7
};
bool isActiveWindow() const;
virtual void setActiveWindow();
bool isFocusEnabled() const;
FocusPolicy focusPolicy() const;
virtual void setFocusPolicy( FocusPolicy );
bool hasFocus() const;
static void setTabOrder( QWidget *, QWidget * );
virtual void setFocusProxy( QWidget * );
QWidget * focusProxy() const;
// Grab functions
void grabMouse();
void grabMouse( const QCursor & );
void releaseMouse();
void grabKeyboard();
void releaseKeyboard();
static QWidget * mouseGrabber();
static QWidget * keyboardGrabber();
// Update/refresh functions
bool isUpdatesEnabled() const;
public slots:
virtual void setUpdatesEnabled( bool enable );
void update();
void update( int x, int y, int w, int h );
void update( const QRect& );
void repaint();
void repaint( bool erase );
void repaint( int x, int y, int w, int h, bool erase=TRUE );
void repaint( const QRect &, bool erase=TRUE );
void repaint( const QRegion &, bool erase=TRUE );
// Widget management functions
virtual void show();
virtual void hide();
#ifndef QT_NO_COMPAT
void iconify() { showMinimized(); }
#endif
virtual void showMinimized();
virtual void showMaximized();
void showFullScreen(); // virtual 3.0
virtual void showNormal();
virtual void polish();
void constPolish() const;
bool close();
void raise();
void lower();
virtual void move( int x, int y );
void move( const QPoint & );
virtual void resize( int w, int h );
void resize( const QSize & );
virtual void setGeometry( int x, int y, int w, int h );
virtual void setGeometry( const QRect & );
public:
virtual bool close( bool alsoDelete );
bool isVisible() const;
bool isVisibleTo(QWidget*) const;
bool isVisibleToTLW() const;
QRect visibleRect() const;
bool isMinimized() const;
virtual QSize sizeHint() const;
virtual QSize minimumSizeHint() const;
virtual QSizePolicy sizePolicy() const;
virtual int heightForWidth(int) const;
virtual void adjustSize();
QLayout * layout() const { return lay_out; }
void updateGeometry();
virtual void reparent( QWidget *parent, WFlags, const QPoint &,
bool showIt=FALSE );
void reparent( QWidget *parent, const QPoint &,
bool showIt=FALSE );
#ifndef QT_NO_COMPAT
void recreate( QWidget *parent, WFlags f, const QPoint & p,
bool showIt=FALSE )
{ reparent(parent,f,p,showIt); }
#endif
void erase();
void erase( int x, int y, int w, int h );
void erase( const QRect & );
void erase( const QRegion & );
void scroll( int dx, int dy );
void scroll( int dx, int dy, const QRect& );
void drawText( int x, int y, const QString &);
void drawText( const QPoint &, const QString &);
// Misc. functions
QWidget * focusWidget() const;
QRect microFocusHint() const;
// drag and drop
bool acceptDrops() const;
virtual void setAcceptDrops( bool on );
// transparency and pseudo transparency
virtual void setAutoMask(bool);
bool autoMask() const;
enum BackgroundOrigin { WidgetOrigin, ParentOrigin };
void setBackgroundOrigin( BackgroundOrigin );
BackgroundOrigin backgroundOrigin() const;
// whats this help
virtual bool customWhatsThis() const;
QWidget * parentWidget() const;
bool testWState( uint n ) const;
bool testWFlags( WFlags n ) const;
static QWidget * find( WId );
static QWidgetMapper *wmapper();
// Event handlers
protected:
bool event( QEvent * );
virtual void mousePressEvent( QMouseEvent * );
virtual void mouseReleaseEvent( QMouseEvent * );
virtual void mouseDoubleClickEvent( QMouseEvent * );
virtual void mouseMoveEvent( QMouseEvent * );
virtual void wheelEvent( QWheelEvent * );
virtual void keyPressEvent( QKeyEvent * );
virtual void keyReleaseEvent( QKeyEvent * );
virtual void focusInEvent( QFocusEvent * );
virtual void focusOutEvent( QFocusEvent * );
virtual void enterEvent( QEvent * );
virtual void leaveEvent( QEvent * );
virtual void paintEvent( QPaintEvent * );
virtual void moveEvent( QMoveEvent * );
virtual void resizeEvent( QResizeEvent * );
virtual void closeEvent( QCloseEvent * );
virtual void dragEnterEvent( QDragEnterEvent * );
virtual void dragMoveEvent( QDragMoveEvent * );
virtual void dragLeaveEvent( QDragLeaveEvent * );
virtual void dropEvent( QDropEvent * );
virtual void showEvent( QShowEvent * );
virtual void hideEvent( QHideEvent * );
virtual void customEvent( QCustomEvent * );
#if defined(_WS_MAC_)
virtual bool macEvent( MSG * ); // Macintosh event
QWidget * mytop; // This widget's top-level widg
int back_type; // Type of background
QPixmap * bg_pix;
virtual void fixport();
virtual void propagateUpdates(int x,int y,int x2,int y2);
#elif defined(_WS_WIN_)
virtual bool winEvent( MSG * ); // Windows event
#elif defined(_WS_X11_)
virtual bool x11Event( XEvent * ); // X11 event
#endif
virtual void updateMask();
// Misc. protected functions
protected:
virtual void styleChange( QStyle& );
virtual void enabledChange( bool );
virtual void backgroundColorChange( const QColor & );
virtual void backgroundPixmapChange( const QPixmap & );
virtual void paletteChange( const QPalette & );
virtual void fontChange( const QFont & );
int metric( int ) const;
virtual void create( WId = 0, bool initializeWindow = TRUE,
bool destroyOldWindow = TRUE );
virtual void destroy( bool destroyWindow = TRUE,
bool destroySubWindows = TRUE );
uint getWState() const;
virtual void setWState( uint );
void clearWState( uint n );
WFlags getWFlags() const;
virtual void setWFlags( WFlags );
void clearWFlags( WFlags n );
virtual void setFRect( const QRect & );
virtual void setCRect( const QRect & );
virtual bool focusNextPrevChild( bool next );
QWExtra *extraData();
QTLWExtra *topData();
QFocusData *focusData();
virtual void setKeyCompression(bool);
virtual void setMicroFocusHint(int x, int y, int w, int h, bool text=TRUE);
private slots:
void focusProxyDestroyed();
private:
void setFontSys();
void setLayout( QLayout *l );
void setWinId( WId );
void showWindow();
void hideWindow();
void sendShowEventsToChildren( bool spontaneous );
void sendHideEventsToChildren( bool spontaneous );
void createTLExtra();
void createExtra();
void deleteExtra();
void createSysExtra();
void deleteSysExtra();
void createTLSysExtra();
void deleteTLSysExtra();
void deactivateWidgetCleanup();
void internalSetGeometry( int, int, int, int, bool );
void reparentFocusWidgets( QWidget * );
QFocusData *focusData( bool create );
void setBackgroundFromMode();
void setBackgroundColorDirect( const QColor & );
void setBackgroundPixmapDirect( const QPixmap & );
void setBackgroundModeDirect( BackgroundMode );
void setBackgroundEmpty();
WId winid;
uint widget_state;
uint widget_flags;
uint propagate_font : 2; // obsolete
uint propagate_palette : 2; // obsolete
uint focus_policy : 4;
uint own_font :1;
uint own_palette :1;
QPoint fpos;
QRect crect;
QColor bg_col;
QPalette pal;
QFont fnt;
QLayout *lay_out;
QWExtra *extra;
static void createMapper();
static void destroyMapper();
static QWidgetList *wList();
static QWidgetList *tlwList();
static QWidgetMapper *mapper;
friend class QApplication;
friend class QBaseApplication;
friend class QPainter;
friend class QFontMetrics;
friend class QFontInfo;
friend class QETWidget;
#if 1 //was #ifdef TOTAL_LOSER_COMPILER but they all seem to be
friend class QLayout;
#else
friend void QLayout::setWidgetLayout( QWidget *, QLayout * );
#endif
private: // Disabled copy constructor and operator=
#if defined(Q_DISABLE_COPY)
QWidget( const QWidget & );
QWidget &operator=( const QWidget & );
#endif
public: // obsolete functions to dissappear or to become inline in 3.0
void setPalette( const QPalette &, bool iReallyMeanIt );
void setFont( const QFont &, bool iReallyMeanIt );
};
inline bool QWidget::testWState( uint f ) const
{ return (widget_state & f) != 0; }
inline bool QWidget::testWFlags( WFlags f ) const
{ return (widget_flags & f) != 0; }
inline WId QWidget::winId() const
{ return winid; }
inline bool QWidget::isTopLevel() const
{ return testWFlags(WType_TopLevel); }
inline bool QWidget::isModal() const
{ return testWFlags(WType_Modal); }
inline bool QWidget::isPopup() const
{ return testWFlags(WType_Popup); }
inline bool QWidget::isDesktop() const
{ return testWFlags(WType_Desktop); }
inline bool QWidget::isEnabled() const
{ return !testWState(WState_Disabled); }
inline const QRect &QWidget::geometry() const
{ return crect; }
inline int QWidget::x() const
{ return fpos.x(); }
inline int QWidget::y() const
{ return fpos.y(); }
inline QPoint QWidget::pos() const
{ return fpos; }
inline QSize QWidget::size() const
{ return crect.size(); }
inline int QWidget::width() const
{ return crect.width(); }
inline int QWidget::height() const
{ return crect.height(); }
inline QRect QWidget::rect() const
{ return QRect(0,0,crect.width(),crect.height()); }
inline int QWidget::minimumWidth() const
{ return minimumSize().width(); }
inline int QWidget::minimumHeight() const
{ return minimumSize().height(); }
inline int QWidget::maximumWidth() const
{ return maximumSize().width(); }
inline int QWidget::maximumHeight() const
{ return maximumSize().height(); }
inline void QWidget::setMinimumSize( const QSize &s )
{ setMinimumSize(s.width(),s.height()); }
inline void QWidget::setMaximumSize( const QSize &s )
{ setMaximumSize(s.width(),s.height()); }
inline void QWidget::setSizeIncrement( const QSize &s )
{ setSizeIncrement(s.width(),s.height()); }
inline void QWidget::setBaseSize( const QSize &s )
{ setBaseSize(s.width(),s.height()); }
inline const QColor &QWidget::backgroundColor() const
{ return bg_col; }
inline const QPalette &QWidget::palette() const
{ return pal; }
inline QFont QWidget::font() const
{ return fnt; }
inline QFontMetrics QWidget::fontMetrics() const
{ return QFontMetrics(font()); }
inline QFontInfo QWidget::fontInfo() const
{ return QFontInfo(font()); }
inline bool QWidget::hasMouseTracking() const
{ return testWState(WState_MouseTracking); }
inline bool QWidget::isFocusEnabled() const
{ return (FocusPolicy)focus_policy != NoFocus; }
inline QWidget::FocusPolicy QWidget::focusPolicy() const
{ return (FocusPolicy)focus_policy; }
inline bool QWidget::isUpdatesEnabled() const
{ return !testWState(WState_BlockUpdates); }
inline void QWidget::update( const QRect &r )
{ update( r.x(), r.y(), r.width(), r.height() ); }
inline void QWidget::repaint()
{ repaint( 0, 0, crect.width(), crect.height(), TRUE ); }
inline void QWidget::repaint( bool erase )
{ repaint( 0, 0, crect.width(), crect.height(), erase ); }
inline void QWidget::repaint( const QRect &r, bool erase )
{ repaint( r.x(), r.y(), r.width(), r.height(), erase ); }
inline void QWidget::erase()
{ erase( 0, 0, crect.width(), crect.height() ); }
inline void QWidget::erase( const QRect &r )
{ erase( r.x(), r.y(), r.width(), r.height() ); }
inline bool QWidget::close()
{ return close( FALSE ); }
inline bool QWidget::isVisible() const
{ return testWState(WState_Visible); }
inline void QWidget::move( const QPoint &p )
{ move( p.x(), p.y() ); }
inline void QWidget::resize( const QSize &s )
{ resize( s.width(), s.height()); }
inline void QWidget::setGeometry( const QRect &r )
{ setGeometry( r.left(), r.top(), r.width(), r.height() ); }
inline void QWidget::drawText( const QPoint &p, const QString &s )
{ drawText( p.x(), p.y(), s ); }
inline QWidget *QWidget::parentWidget() const
{ return (QWidget *)QObject::parent(); }
inline QWidgetMapper *QWidget::wmapper()
{ return mapper; }
inline uint QWidget::getWState() const
{ return widget_state; }
inline void QWidget::setWState( uint f )
{ widget_state |= f; }
inline void QWidget::clearWState( uint f )
{ widget_state &= ~f; }
inline Qt::WFlags QWidget::getWFlags() const
{ return widget_flags; }
inline void QWidget::setWFlags( WFlags f )
{ widget_flags |= f; }
inline void QWidget::clearWFlags( WFlags f )
{ widget_flags &= ~f; }
inline void QWidget::constPolish() const
{
if ( !testWState(WState_Polished) ) {
QWidget* that = (QWidget*) this;
that->polish();
that->setWState(WState_Polished); // be on the safe side...
}
}
// Extra QWidget data
// - to minimize memory usage for members that are seldom used.
// - top-level widgets have extra extra data to reduce cost further
qt'QWidget::constPolish() (./qt-2.1.0/include/qwidget.h:693)
inline void QWidget::constPolish() const
{
if ( !testWState(WState_Polished) ) {
QWidget* that = (QWidget*) this;
that->polish();
that->setWState(WState_Polished); // be on the safe side...
}
}
// Extra QWidget data
// - to minimize memory usage for members that are seldom used.
// - top-level widgets have extra extra data to reduce cost further
qt'QWidget::QWidget() (./qt-2.1.0/src/kernel/qwidget.cpp:665)
QWidget::QWidget( QWidget *parent, const char *name, WFlags f )
: QObject( parent, name ), QPaintDevice( QInternal::Widget )
{
isWidget = TRUE; // is a widget
winid = 0; // default attributes
widget_state = 0;
widget_flags = f;
focus_policy = 0;
own_font = 0;
own_palette = 0;
lay_out = 0;
extra = 0; // no extra widget info
bg_col = pal.normal().background(); // default background color
create(); // platform-dependent init
pal = isTopLevel() ? QApplication::palette() : parentWidget()->palette();
fnt = isTopLevel() ? QApplication::font() : parentWidget()->font();
if ( !isDesktop() )
setBackgroundFromMode(); //### parts of this are done in create but not all (see reparent(...) )
// make sure move/resize events are sent to all widgets
QApplication::postEvent( this, new QMoveEvent( fpos, fpos ) );
QApplication::postEvent( this, new QResizeEvent(crect.size(),
crect.size()) );
if ( isTopLevel() ) {
setWState( WState_ForceHide );
if ( testWFlags( WType_Modal ) )
setWState( WState_Modal ); // default for modal windows is to be modal
QFocusData *fd = focusData( TRUE );
if ( fd->focusWidgets.findRef(this) < 0 )
fd->focusWidgets.append( this );
} else {
if ( !parentWidget()->isEnabled() )
setWState( WState_Disabled ); // propagate enabled state
if ( parentWidget()->isVisibleTo( 0 ) )
setWState( WState_ForceHide ); // new widgets do not show up in already visible parents
}
}
/*!
Destructs the widget.
All children of this widget are deleted first.
The application exits if this widget is (was) the main widget.
*/
qt'QWidget::~QWidget() (./qt-2.1.0/src/kernel/qwidget.cpp:712)
QWidget::~QWidget()
{
#if defined (CHECK_STATE)
if ( paintingActive() )
qWarning( "%s (%s): deleted while being painted", className(), name() );
#endif
// Remove myself and all children from the can-take-focus list
QFocusData *f = focusData( FALSE );
if ( f ) {
QListIterator<QWidget> it(f->focusWidgets);
QWidget *w;
while ( (w = it.current()) ) {
++it;
QWidget * p = w;
while( p && p != this )
p = p->parentWidget();
if ( p ) // my descendant
f->focusWidgets.removeRef( w );
}
}
if ( QApplication::main_widget == this ) { // reset main widget
QApplication::main_widget = 0;
if (qApp)
qApp->quit();
}
if ( focusWidget() == this )
clearFocus();
if ( QApplication::focus_widget == this )
QApplication::focus_widget = 0;
if ( isTopLevel() && isVisible() && winId() )
hide();
// ###shall we really emit lastWindowClosed? here as well? It's
// ###not closed but destroyed....
// A parent widget must destroy all its children before destroying itself
if ( childObjects ) { // delete children objects
QObjectListIt it(*childObjects);
QObject *obj;
while ( (obj=it.current()) ) {
++it;
obj->parentObj = 0;
// ### nest line is a QGList workaround - remove in 3.0
childObjects->removeRef( obj );
delete obj;
}
delete childObjects;
childObjects = 0;
}
if ( extra )
deleteExtra();
destroy(); // platform-dependent cleanup
}
/*!
\internal
Creates the global widget mapper.
The widget mapper converts window handles to widget pointers.
\sa destroyMapper()
*/
qt'QWidget::createMapper() (./qt-2.1.0/src/kernel/qwidget.cpp:777)
void QWidget::createMapper()
{
mapper = new QWidgetMapper;
CHECK_PTR( mapper );
}
/*!
\internal
Destroys the global widget mapper.
\sa createMapper()
*/
qt'QWidget::destroyMapper() (./qt-2.1.0/src/kernel/qwidget.cpp:789)
void QWidget::destroyMapper()
{
if ( !mapper ) // already gone
return;
QWidgetIntDictIt it( *((QWidgetIntDict*)mapper) );
QWidgetMapper * myMapper = mapper;
mapper = 0;
register QWidget *w;
while ( (w=it.current()) ) { // remove parents widgets
++it;
if ( !w->parentObj ) // widget is a parent
w->destroy( TRUE, TRUE );
}
delete myMapper;
}
qt'QWidget::wList() (./qt-2.1.0/src/kernel/qwidget.cpp:828)
QWidgetList *QWidget::wList()
{
return wListInternal( mapper, FALSE );
}
/*!
\internal
Returns a list of all top level widgets.
\sa wList(), QApplication::topLevelWidgets()
*/
qt'QWidget::tlwList() (./qt-2.1.0/src/kernel/qwidget.cpp:839)
QWidgetList *QWidget::tlwList()
{
return wListInternal( mapper, TRUE );
}
qt'QWidget::setWinId() (./qt-2.1.0/src/kernel/qwidget.cpp:845)
void QWidget::setWinId( WId id ) // set widget identifier
{
if ( !mapper ) // mapper destroyed
return;
if ( winid )
mapper->remove( winid );
winid = id;
#if defined(_WS_X11_)
hd = id; // X11: hd == ident
#endif
if ( id )
mapper->insert( this );
}
/*!
\internal
Returns a pointer to the block of extra widget data.
*/
qt'QWidget::extraData() (./qt-2.1.0/src/kernel/qwidget.cpp:865)
QWExtra *QWidget::extraData()
{
return extra;
}
/*!
\internal
Returns a pointer to the block of extra toplevel widget data.
This data is guaranteed to exist for toplevel widgets.
*/
qt'QWidget::topData() (./qt-2.1.0/src/kernel/qwidget.cpp:878)
QTLWExtra *QWidget::topData()
{
createTLExtra();
return extra->topextra;
}
qt'QWidget::createTLExtra() (./qt-2.1.0/src/kernel/qwidget.cpp:884)
void QWidget::createTLExtra()
{
if ( !extra )
createExtra();
if ( !extra->topextra ) {
QTLWExtra* x = extra->topextra = new QTLWExtra;
x->icon = 0;
x->focusData = 0;
x->fsize = crect.size();
x->incw = x->inch = 0;
x->basew = x->baseh = 0;
x->iconic = 0;
x->fullscreen = 0;
x->showMode = 0;
x->normalGeometry = QRect(0,0,-1,-1);
#if defined(_WS_X11_)
x->embedded = 0;
x->parentWinId = 0;
x->dnd = 0;
x->uspos = 0;
x->ussize = 0;
#endif
createTLSysExtra();
}
}
/*!
\internal
Creates the widget extra data.
*/
qt'QWidget::createExtra() (./qt-2.1.0/src/kernel/qwidget.cpp:915)
void QWidget::createExtra()
{
if ( !extra ) { // if not exists
extra = new QWExtra;
CHECK_PTR( extra );
extra->minw = extra->minh = 0;
extra->maxw = extra->maxh = QWIDGETSIZE_MAX;
extra->bg_pix = 0;
extra->focus_proxy = 0;
extra->curs = 0;
extra->topextra = 0;
extra->bg_mode = PaletteBackground;
extra->style = 0;
createSysExtra();
}
}
/*!
\internal
Deletes the widget extra data.
*/
qt'QWidget::deleteExtra() (./qt-2.1.0/src/kernel/qwidget.cpp:938)
void QWidget::deleteExtra()
{
if ( extra ) { // if exists
delete extra->bg_pix;
delete extra->curs;
deleteSysExtra();
if ( extra->topextra ) {
deleteTLSysExtra();
delete extra->topextra->icon;
delete extra->topextra->focusData;
delete extra->topextra;
}
delete extra;
// extra->xic destroyed in QWidget::destroy()
extra = 0;
}
}
/*!
\internal
This function is called when a widget is hidden or destroyed.
It resets some application global pointers that should only refer active,
visible widgets.
*/
qt'QWidget::deactivateWidgetCleanup() (./qt-2.1.0/src/kernel/qwidget.cpp:964)
void QWidget::deactivateWidgetCleanup()
{
extern QWidget *qt_button_down;
// If this was the active application window, reset it
if ( this == QApplication::active_window )
QApplication::active_window = 0;
// If the is the active mouse press widget, reset it
if ( qt_button_down == this )
qt_button_down = 0;
}
/*!
Returns a pointer to the widget with window identifer/handle \a id.
The window identifier type depends by the underlying window system,
see qwindowdefs.h for the actual definition.
If there is no widget with this identifier, a null pointer is returned.
\sa wmapper(), id()
*/
qt'QWidget::find() (./qt-2.1.0/src/kernel/qwidget.cpp:986)
QWidget *QWidget::find( WId id )
{
return mapper ? mapper->find( id ) : 0;
}
/*!
\fn QWidgetMapper *QWidget::wmapper()
\internal
Returns a pointer to the widget mapper.
The widget mapper is an internal dictionary that is used to map from
window identifiers/handles to widget pointers.
\sa find(), id()
*/
/*!
\fn WFlags QWidget::getWFlags() const
Returns the widget flags for this this widget.
Widget flags are internal, not meant for public use.
\sa testWFlags(), setWFlags(), clearWFlags()
*/
/*!
\fn void QWidget::setWFlags( WFlags f )
Sets the widget flags \a f.
Widget flags are internal, not meant for public use.
\sa testWFlags(), getWFlags(), clearWFlags()
*/
/*!
\fn void QWidget::clearWFlags( WFlags f )
Clears the widget flags \a f.
Widget flags are internal, not meant for public use.
\sa testWFlags(), getWFlags(), setWFlags()
*/
/*!
\fn WId QWidget::winId() const
Returns the window system identifier of the widget.
Portable in principle, but if you use it you are probably about to do
something non-portable. Be careful.
\sa find()
*/
/*!
Returns the GUI style for this widget
\sa QWidget::setStyle(), QApplication::setStyle(),
QApplication::style()
*/
qt'QWidget::style() (./qt-2.1.0/src/kernel/qwidget.cpp:1051)
QStyle& QWidget::style() const
{
if ( extra && extra->style )
return *extra->style;
return qApp->style();
}
/*!
\fn void QWidget::styleChange( QStyle& oldStyle )
This virtual function is called when the style of the widgets.
changes.\a oldStyle is the
previous GUI style; you can get the new style from style().
Reimplement this function if your widget needs to know when its GUI
style changes. You will almost certainly need to update the widget
using update().
The default implementation updates the widget including its
geometry.
\sa QApplication::setStyle(), style(), update(), updateGeometry()
*/
qt'QWidget::styleChange() (./qt-2.1.0/src/kernel/qwidget.cpp:1076)
void QWidget::styleChange( QStyle& )
{
update();
updateGeometry();
}
/*!
\fn bool QWidget::isTopLevel() const
Returns TRUE if the widget is a top-level widget, otherwise FALSE.
A top-level widget is a widget which usually has a frame and a \link
setCaption() caption\endlink (title bar). \link isPopup() Popup\endlink
and \link isDesktop() desktop\endlink widgets are also top-level
widgets.
A top-level widgets can have a \link parentWidget() parent
widget\endlink. It will then be grouped with its parent: deleted
when the parent is deleted, minimized when the parent is minimized
etc. If supported by the window manager, it will also have a common
taskbar entry with its parent.
QDialog and QMainWindow widgets are by default top-level, even if a
parent widget is specified in the constructor. This behavior is
specified by the \c WType_TopLevel widget flag.
Child widgets are the opposite of top-level widgets.
\sa topLevelWidget(), isModal(), isPopup(), isDesktop(), parentWidget()
*/
/*!
\fn bool QWidget::isModal() const
Returns TRUE if the widget is a modal widget, otherwise FALSE.
A modal widget is also a top-level widget.
\sa isTopLevel(), QDialog
*/
/*!
\fn bool QWidget::isPopup() const
Returns TRUE if the widget is a popup widget, otherwise FALSE.
A popup widget is created by specifying the widget flag \c WType_Popup
to the widget constructor.
A popup widget is also a top-level widget.
\sa isTopLevel()
*/
/*!
\fn bool QWidget::isDesktop() const
Returns TRUE if the widget is a desktop widget, otherwise FALSE.
A desktop widget is also a top-level widget.
\sa isTopLevel(), QApplication::desktop()
*/
/*!
\fn bool QWidget::isEnabled() const
Returns TRUE if the widget is enabled, or FALSE if it is disabled.
\sa setEnabled()
*/
/*!
Returns TRUE if this widget would become enabled if \a ancestor is
enabled.
This is the case if neither the widget itself nor every parent up to
but excluding \a ancestor has been explicitely disabled.
isEnabledTo(0) is equivalent to isEnabled().
\sa setEnabled() isEnabled()
*/
qt'QWidget::isEnabledTo() (./qt-2.1.0/src/kernel/qwidget.cpp:1158)
bool QWidget::isEnabledTo(QWidget* ancestor) const
{
const QWidget * w = this;
while ( w && !w->testWFlags( WState_ForceDisabled )
&& !w->isTopLevel()
&& w->parentWidget()
&& w->parentWidget()!=ancestor
)
w = w->parentWidget();
return !w->testWFlags( WState_ForceDisabled );
}
/*!\obsolete
This function is deprecated. It is equivalent to isEnabled()
\sa setEnabled() isEnabled()
*/
qt'QWidget::isEnabledToTLW() (./qt-2.1.0/src/kernel/qwidget.cpp:1178)
bool QWidget::isEnabledToTLW() const
{
return isEnabledTo(0);
}
/*!
Enables widget input events if \a enable is TRUE, otherwise disables
input events.
An enabled widget receives keyboard and mouse events; a disabled
widget does not. Note that an enabled widget receives keyboard
events only when it is in focus.
Some widgets display themselves differently when they are disabled.
For example a button might draw its label grayed out. If your widget
needs to know when it becomes enabled or disabled, you can
reimplement the enabledChange() function.
Disabling a widget implicitely disables all its children. Enabling
respectively enables all child widgets unless they have been
explicitely disabled.
\sa isEnabled(), isEnabledTo(), QKeyEvent, QMouseEvent, enabledChange()
*/
qt'QWidget::setEnabled() (./qt-2.1.0/src/kernel/qwidget.cpp:1204)
void QWidget::setEnabled( bool enable )
{
if ( enable )
clearWState( WState_ForceDisabled );
else
setWState( WState_ForceDisabled );
if ( !isTopLevel() && !parentWidget()->isEnabled() && enable )
return; // nothing we can do
if ( enable ) {
if ( testWState(WState_Disabled) ) {
clearWState( WState_Disabled );
setBackgroundFromMode();
enabledChange( TRUE );
if ( children() ) {
QObjectListIt it( *children() );
QWidget *w;
while( (w=(QWidget *)it.current()) != 0 ) {
++it;
if ( w->isWidgetType() && !w->testWState( WState_ForceDisabled ) )
w->setEnabled( TRUE );
}
}
}
} else {
if ( !testWState(WState_Disabled) ) {
if ( focusWidget() == this )
focusNextPrevChild( TRUE );
setWState( WState_Disabled );
setBackgroundFromMode();
enabledChange( FALSE );
if ( children() ) {
QObjectListIt it( *children() );
QWidget *w;
while( (w=(QWidget *)it.current()) != 0 ) {
++it;
if ( w->isWidgetType() && w->isEnabled() ) {
w->setEnabled( FALSE );
w->clearWState( WState_ForceDisabled );
}
}
}
}
}
}
/*!
\fn void QWidget::enabledChange( bool oldEnabled )
This virtual function is called from setEnabled(). \a oldEnabled is the
previous setting; you can get the new setting from isEnabled().
Reimplement this function if your widget needs to know when it becomes
enabled or disabled. You will almost certainly need to update the widget
using update().
The default implementation repaints the visible part of the widget.
\sa setEnabled(), isEnabled(), repaint(), update(), visibleRect()
*/
qt'QWidget::enabledChange() (./qt-2.1.0/src/kernel/qwidget.cpp:1266)
void QWidget::enabledChange( bool )
{
update();
}
/*!
\fn QRect QWidget::frameGeometry() const
Returns the geometry of the widget, relative to its parent and
including the window frame.
See the \link geometry.html Window Geometry documentation\endlink
for an overview of geometry issues with top-level widgets.
\sa geometry(), x(), y(), pos()
*/
qt'QWidget::frameGeometry() (./qt-2.1.0/src/kernel/qwidget.cpp:1283)
QRect QWidget::frameGeometry() const
{
return QRect(fpos,frameSize());
}
/*!
\fn const QRect &QWidget::geometry() const
Returns the geometry of the widget, relative to its parent widget
and excluding the window frame.
See the \link geometry.html Window Geometry documentation\endlink
for an overview of geometry issues with top-level widgets.
\sa frameGeometry(), size(), rect()
*/
/*!
\fn int QWidget::x() const
Returns the x coordinate of the widget, relative to its parent
widget and including the window frame.
See the \link geometry.html Window Geometry documentation\endlink
for an overview of geometry issues with top-level widgets.
\sa frameGeometry(), y(), pos()
*/
/*!
\fn int QWidget::y() const
Returns the y coordinate of the widget, relative to its parent
widget and including the window frame.
See the \link geometry.html Window Geometry documentation\endlink
for an overview of geometry issues with top-level widgets.
\sa frameGeometry(), x(), pos()
*/
/*!
\fn QPoint QWidget::pos() const
Returns the position of the widget in its parent widget, including
the window frame.
See the \link geometry.html Window Geometry documentation\endlink
for an overview of geometry issues with top-level widgets.
\sa move(), frameGeometry(), x(), y()
*/
/*!
\fn QSize QWidget::size() const
Returns the size of the widget, excluding the window frame.
\sa geometry(), width(), height()
*/
/*!
\fn int QWidget::width() const
Returns the width of the widget, excluding the window frame.
See the \link geometry.html Window Geometry documentation\endlink
for an overview of geometry issues with top-level widgets.
\sa geometry(), height(), size()
*/
/*!
\fn int QWidget::height() const
Returns the height of the widget, excluding the window frame.
See the \link geometry.html Window Geometry documentation\endlink
for an overview of geometry issues with top-level widgets.
\sa geometry(), width(), size()
*/
/*!
\fn QRect QWidget::rect() const
Returns the the internal geometry of the widget, excluding the window frame.
rect() equals QRect(0,0,width(),height()).
See the \link geometry.html Window Geometry documentation\endlink
for an overview of geometry issues with top-level widgets.
\sa size()
*/
/*!
Returns the bounding rectangle of the widget's children.
*/
qt'QWidget::childrenRect() (./qt-2.1.0/src/kernel/qwidget.cpp:1376)
QRect QWidget::childrenRect() const
{
QRect r( 0, 0, 0, 0 );
if ( !children() )
return r;
QObjectListIt it( *children() ); // iterate over all children
QObject *obj;
while ( (obj=it.current()) ) {
++it;
if ( obj->isWidgetType() )
r = r.unite( ((QWidget*)obj)->geometry() );
}
return r;
}
/*!
Returns the combined region of the widget's children geometry().
*/
qt'QWidget::childrenRegion() (./qt-2.1.0/src/kernel/qwidget.cpp:1395)
QRegion QWidget::childrenRegion() const
{
QRegion r;
if ( !children() )
return r;
QObjectListIt it( *children() ); // iterate over all children
QObject *obj;
while ( (obj=it.current()) ) {
++it;
if ( obj->isWidgetType() )
r = r.unite( ((QWidget*)obj)->geometry() );
}
return r;
}
/*!
Returns the minimum widget size.
The widget cannot be resized to a smaller size than the minimum widget
size.
If the returned minimum size equals (0,0) then it means that there are
no constraints on the minimum size. However, Qt does nevertheless not
allow you to shrink widgets to less than 1 pixel width/height.
\sa maximumWidth(), maximumHeight(), setMinimumSize(),
maximumSize(), sizeIncrement()
*/
qt'QWidget::minimumSize() (./qt-2.1.0/src/kernel/qwidget.cpp:1425)
QSize QWidget::minimumSize() const
{
return extra ? QSize(extra->minw,extra->minh) : QSize(0,0);
}
/*!
Returns the maximum widget size.
The widget cannot be resized to a larger size than the maximum widget
size.
\sa maximumWidth(), maximumHeight(), setMaximumSize(),
minimumSize(), sizeIncrement()
*/
qt'QWidget::maximumSize() (./qt-2.1.0/src/kernel/qwidget.cpp:1440)
QSize QWidget::maximumSize() const
{
return extra ? QSize(extra->maxw,extra->maxh)
: QSize(QWIDGETSIZE_MAX,QWIDGETSIZE_MAX);
}
/*!
\fn int QWidget::minimumWidth() const
Returns the widget's minimum width.
\sa minimumSize(), minimumHeight()
*/
/*!
\fn int QWidget::minimumHeight() const
Returns the widget's minimum height.
\sa minimumSize(), minimumWidth()
*/
/*!
\fn int QWidget::maximumWidth() const
Returns the widget's maximum width.
\sa maximumSize(), maximumHeight()
*/
/*!
\fn int QWidget::maximumHeight() const
Returns the widget's maximum height.
\sa maximumSize(), maximumWidth()
*/
/*!
Returns the widget size increment.
\sa setSizeIncrement(), minimumSize(), maximumSize()
*/
qt'QWidget::sizeIncrement() (./qt-2.1.0/src/kernel/qwidget.cpp:1486)
QSize QWidget::sizeIncrement() const
{
return extra && extra->topextra
? QSize(extra->topextra->incw,extra->topextra->inch)
: QSize(0,0);
}
/*!
Returns the widget base size
The base size is used to calculate a proper widget size in case the
widget defines sizeIncrement().
\sa setBaseSize(), setSizeIncrement()
*/
qt'QWidget::baseSize() (./qt-2.1.0/src/kernel/qwidget.cpp:1502)
QSize QWidget::baseSize() const
{
return extra && extra->topextra
? QSize(extra->topextra->basew,extra->topextra->baseh)
: QSize(0,0);
}
/*!
Sets both the minimum and maximum sizes of the widget to \a s,
thereby preventing it from ever growing or shrinking.
\sa setMaximumSize() setMinimumSize()
*/
qt'QWidget::setFixedSize() (./qt-2.1.0/src/kernel/qwidget.cpp:1517)
void QWidget::setFixedSize( const QSize & s)
{
setMinimumSize( s );
setMaximumSize( s );
resize( s );
}
/*!
\overload void QWidget::setFixedSize( int w, int h )
*/
qt'QWidget::setFixedSize() (./qt-2.1.0/src/kernel/qwidget.cpp:1529)
void QWidget::setFixedSize( int w, int h )
{
setMinimumSize( w, h );
setMaximumSize( w, h );
resize( w, h );
}
/*!
Sets the minimum width of the widget to \a w without changing the
height. Provided for convenience.
\sa sizeHint() minimumSize() maximumSize()
setFixedSize() and more
*/
qt'QWidget::setMinimumWidth() (./qt-2.1.0/src/kernel/qwidget.cpp:1545)
void QWidget::setMinimumWidth( int w )
{
setMinimumSize( w, minimumSize().height() );
}
/*!
Sets the minimum height of the widget to \a h without changing the
width. Provided for convenience.
\sa sizeHint() minimumSize() maximumSize() setFixedSize() and more
*/
qt'QWidget::setMinimumHeight() (./qt-2.1.0/src/kernel/qwidget.cpp:1558)
void QWidget::setMinimumHeight( int h )
{
setMinimumSize( minimumSize().width(), h );
}
/*!
Sets the maximum width of the widget to \a w without changing the
height. Provided for convenience.
\sa sizeHint() minimumSize() maximumSize() setFixedSize() and more
*/
qt'QWidget::setMaximumWidth() (./qt-2.1.0/src/kernel/qwidget.cpp:1571)
void QWidget::setMaximumWidth( int w )
{
setMaximumSize( w, maximumSize().height() );
}
/*!
Sets the maximum height of the widget to \a h without changing the
width. Provided for convenience.
\sa sizeHint() minimumSize() maximumSize() setFixedSize() and more
*/
qt'QWidget::setMaximumHeight() (./qt-2.1.0/src/kernel/qwidget.cpp:1584)
void QWidget::setMaximumHeight( int h )
{
setMaximumSize( maximumSize().width(), h );
}
/*!
Sets both the minimum and maximum width of the widget to \a w
without changing the heights. Provided for convenience.
\sa sizeHint() minimumSize() maximumSize() setFixedSize() and more
*/
qt'QWidget::setFixedWidth() (./qt-2.1.0/src/kernel/qwidget.cpp:1597)
void QWidget::setFixedWidth( int w )
{
setMinimumSize( w, minimumSize().height() );
setMaximumSize( w, maximumSize().height() );
}
/*!
Sets both the minimum and maximum heights of the widget to \a h
without changing the widths. Provided for convenience.
\sa sizeHint() minimumSize() maximumSize() setFixedSize() and more
*/
qt'QWidget::setFixedHeight() (./qt-2.1.0/src/kernel/qwidget.cpp:1611)
void QWidget::setFixedHeight( int h )
{
setMinimumSize( minimumSize().width(), h );
setMaximumSize( maximumSize().width(), h );
}
/*!
Translates the widget coordinate \a pos to a coordinate in the parent widget.
Same as mapToGlobal() if the widget has no parent.
\sa mapFromParent()
*/
qt'QWidget::mapToParent() (./qt-2.1.0/src/kernel/qwidget.cpp:1625)
QPoint QWidget::mapToParent( const QPoint &pos ) const
{
return pos + crect.topLeft();
}
/*!
Translates the parent widget coordinate \a pos to widget coordinates.
Same as mapFromGlobal() if the widget has no parent.
\sa mapToParent()
*/
qt'QWidget::mapFromParent() (./qt-2.1.0/src/kernel/qwidget.cpp:1638)
QPoint QWidget::mapFromParent( const QPoint &pos ) const
{
return pos - crect.topLeft();
}
/*!
Returns the top-level widget for this widget, i.e. the grandparent
widget that has a window-system frame (or at least may have one) and
has no parent widget inside this application.
\sa isTopLevel()
*/
qt'QWidget::topLevelWidget() (./qt-2.1.0/src/kernel/qwidget.cpp:1652)
QWidget *QWidget::topLevelWidget() const
{
QWidget *w = (QWidget *)this;
QWidget *p = w->parentWidget();
while ( !w->testWFlags(WType_TopLevel) && p ) {
w = p;
p = p->parentWidget();
}
return w;
}
// Please do NOT remove the FAQ answer from this doc again. It's a
// FAQ, it remains a FAQ, and people apparently will not follow three
// links to find the right answer.
/*!
Sets the widget to be cleared to the fixed color \a color before
paintEvent() is called.
Note that using this function is very often a mistake.
If you want to set the background color of a widget to one of the
"usual" colors, setBackgroundMode() is usually the best function.
For example, man widgets that usually use white backgrounds (and
black text on it) can use this:
\code
thatWidget->setBackgroundMode( QWidget::PaletteBase );
\endcode
If you want to change the color scheme of a widget, the setPalette()
function is better suited. Here is how to set \e thatWidget to use a
light green (RGB value 80, 255, 80) as background color, with shades
of green used for all the 3D effects:
\code
thatWidget->setPalette( QPalette( QColor(80, 255, 80) ) );
\endcode
A fixed background color sometimes is just the right thing, but if
you use it, make sure that your application looks right when the
desktop color scheme has been changed. (On X11, a quick way to test
is e.g. "./yourapp -bg paleblue". On Windows, you have to use the
control panel.)
\sa setPalette(), QApplication::setPalette(), backgroundColor(),
setBackgroundPixmap(), setBackgroundMode()
*/
qt'QWidget::setBackgroundColor() (./qt-2.1.0/src/kernel/qwidget.cpp:1702)
void QWidget::setBackgroundColor( const QColor &color )
{
setBackgroundModeDirect( FixedColor );
setBackgroundColorDirect( color );
}
/*!
Sets the background pixmap of the widget to \e pixmap.
The background pixmap is tiled to cover the entire widget. Note
that some widgets do not work well with a background pixmap, for
example QLineEdit.
If \a pixmap is part of the widget's palette(), we recommend calling
setBackgroundMode() instead.
A fixed background pixmap sometimes is just the right thing, but if
you use it, make sure that your application looks right when the
desktop color scheme has been changed. (On X11, a quick way to test
is e.g. "./yourapp -bg paleblue". On Windows, you have to use the
control panel.)
\sa setBackgroundMode(), backgroundPixmap(), backgroundPixmapChange(),
setBackgroundColor()
*/
qt'QWidget::setBackgroundPixmap() (./qt-2.1.0/src/kernel/qwidget.cpp:1729)
void QWidget::setBackgroundPixmap( const QPixmap &pixmap )
{ // This function is called with a null pixmap by setBackgroundEmpty().
setBackgroundPixmapDirect( pixmap );
setBackgroundModeDirect( FixedPixmap );
}
qt'QWidget::setBackgroundFromMode() (./qt-2.1.0/src/kernel/qwidget.cpp:1736)
void QWidget::setBackgroundFromMode()
{
QColorGroup::ColorRole r = QColorGroup::Background;
if ( extra ) {
int i = (BackgroundMode)extra->bg_mode;
if ( i == FixedColor || i == FixedPixmap || i == NoBackground ) {
// Mode is for fixed color, not one based on palette,
// so nothing to do.
return;
}
switch( i ) {
case PaletteForeground:
r = QColorGroup::Foreground;
break;
case PaletteButton:
r = QColorGroup::Button;
break;
case PaletteLight:
r = QColorGroup::Light;
break;
case PaletteMidlight:
r = QColorGroup::Midlight;
break;
case PaletteDark:
r = QColorGroup::Dark;
break;
case PaletteMid:
r = QColorGroup::Mid;
break;
case PaletteText:
r = QColorGroup::Text;
break;
case PaletteBrightText:
r = QColorGroup::BrightText;
break;
case PaletteBase:
r = QColorGroup::Base;
break;
case PaletteBackground:
r = QColorGroup::Background;
break;
case PaletteShadow:
r = QColorGroup::Shadow;
break;
case PaletteHighlight:
r = QColorGroup::Highlight;
break;
case PaletteHighlightedText:
r = QColorGroup::HighlightedText;
break;
}
}
QPixmap * p = colorGroup().brush( r ).pixmap();
if ( p )
setBackgroundPixmapDirect( *p );
else
setBackgroundColorDirect( colorGroup().color( r ) );
}
/*!
Returns the mode most recently set by setBackgroundMode(). The
default is PaletteBackground.
\sa BackgroundMode setBackgroundMode()
*/
QWidget::BackgroundMode QWidget::backgroundMode() const
{
return extra ? (BackgroundMode)extra->bg_mode : PaletteBackground;
}
/*! \enum QWidget::BackgroundMode
This enum describes how the background of a widget changes, as the
widget's palette changes.
The background is what the widget contains when paintEvent() is
called. To minimize flicker, this should be the most common color
or pixmap in the widget. For \c PaletteBackground, use
colorGroup().brush( \c QColorGroup::Background ), and so on. There
are also three special values, listed at the end: <ul>
<li> \c PaletteForeground
<li> \c PaletteBackground
<li> \c PaletteButton
<li> \c PaletteLight
<li> \c PaletteMidlight
<li> \c PaletteDark
<li> \c PaletteMid
<li> \c PaletteText
<li> \c PaletteBrightText
<li> \c PaletteButtonText
<li> \c PaletteBase
<li> \c PaletteShadow
<li> \c PaletteHighlight
<li> \c PaletteHighlightedText
<li> \c NoBackground - the widget is not cleared before paintEvent().
If the widget's paint event always draws on all the pixels, using
this mode can be both fast and flicker-free.
<li> \c FixedColor - the widget is cleared to a fixed color,
normally different from all the ones in the palette(). Set using
BackgroundColor().
<li> \c FixedPixmap - the widget is cleared to a fixed pixmap,
normally different from all the ones in the palette(). Set using
setBackgroundPixmap().
</ul>
\c FixedColor and \c FixedPixmap sometimes are just the right
thing, but if you use them, make sure that your application looks
right when the desktop color scheme has been changed. (On X11, a
quick way to test is e.g. "./yourapp -bg paleblue". On Windows, you
have to use the control panel.)
\sa setBackgroundMode() backgroundMode() setBackgroundPixmap()
setBackgroundColor()
*/
/*!
Tells the window system how to clear this widget when sending a
paint event. In other words, this decides how the widgets looks
when paintEvent() is called.
For most widgets the default (PaletteBackground, normally
gray) suffices, but some need to use PaletteBase (the
background color for text output, normally white) and a few need
other colors.
QListBox, which is "sunken" and uses the base color to contrast with
its environment, does this:
\code
setBackgroundMode( PaletteBase );
\endcode
Note that two of the BackgroundMode values cannot be used with this
function. For \c FixedPixmap, call setBackgroundPixmap() instead,
and for \c FixedColor, call setBackgroundColor().
*/
qt'QWidget::setBackgroundMode() (./qt-2.1.0/src/kernel/qwidget.cpp:1876)
void QWidget::setBackgroundMode( BackgroundMode m )
{
if ( m == NoBackground )
setBackgroundEmpty();
else if ( m == FixedColor || m == FixedPixmap ) {
qWarning("May not pass FixedColor or FixedPixmap to setBackgroundMode()");
return;
}
setBackgroundModeDirect(m);
}
/*!
\internal
*/
qt'QWidget::setBackgroundModeDirect() (./qt-2.1.0/src/kernel/qwidget.cpp:1890)
void QWidget::setBackgroundModeDirect( BackgroundMode m )
{
if (m==PaletteBackground && !extra) return;
createExtra();
if ((BackgroundMode)extra->bg_mode != m) {
extra->bg_mode = m;
setBackgroundFromMode();
}
}
/*!
\fn const QColor &QWidget::backgroundColor() const
Returns the background color of this widget, which is normally set
implicitly by setBackgroundMode(), but can also be set explicitly by
setBackgroundColor().
If there is a background pixmap (set using setBackgroundPixmap()),
then the return value of this function is indeterminate.
\sa setBackgroundColor(), foregroundColor(), colorGroup(), palette()
*/
/*!
Returns the foreground color of this widget.
The foreground color is also accessible as colorGroup().foreground().
\sa backgroundColor(), colorGroup()
*/
qt'QWidget::foregroundColor() (./qt-2.1.0/src/kernel/qwidget.cpp:1923)
const QColor &QWidget::foregroundColor() const
{
return colorGroup().foreground();
}
/*!
\fn void QWidget::backgroundColorChange( const QColor &oldBackgroundColor )
This virtual function is called from setBackgroundColor().
\e oldBackgroundColor is the previous background color; you can get the new
background color from backgroundColor().
Reimplement this function if your widget needs to know when its
background color changes. You will almost certainly need to call
this implementation of the function.
\sa setBackgroundColor(), backgroundColor(), setPalette(), repaint(),
update()
*/
qt'QWidget::backgroundColorChange() (./qt-2.1.0/src/kernel/qwidget.cpp:1944)
void QWidget::backgroundColorChange( const QColor & )
{
update();
}
/*!
Returns the background pixmap if one has been set. If the widget
has backgroundMode() NoBackground, the return value is a pixmap for
which QPixmao:isNull() is true. If the widget has no pixmap is the
background, the return value is a null pointer.
\sa setBackgroundPixmap(), setBackgroundMode()
*/
qt'QWidget::backgroundPixmap() (./qt-2.1.0/src/kernel/qwidget.cpp:1959)
const QPixmap *QWidget::backgroundPixmap() const
{
return (extra && extra->bg_pix) ? extra->bg_pix : 0;
}
/*!
\fn void QWidget::backgroundPixmapChange( const QPixmap & oldBackgroundPixmap )
This virtual function is called from setBackgroundPixmap().
\e oldBackgroundPixmap is the previous background pixmap; you can get the
new background pixmap from backgroundPixmap().
Reimplement this function if your widget needs to know when its
background pixmap changes. You will almost certainly need to call
this implementation of the function.
\sa setBackgroundPixmap(), backgroundPixmap(), repaint(), update()
*/
qt'QWidget::backgroundPixmapChange() (./qt-2.1.0/src/kernel/qwidget.cpp:1979)
void QWidget::backgroundPixmapChange( const QPixmap & )
{
update();
}
/*!
Returns the current color group of the widget palette.
The color group is determined by the state of the widget.
A disabled widget returns the QPalette::disabled() color group, a
widget in the window with keyboard focus returns the
QPalette::active() color group and all inactive widgets return the
QPalette::inactive() color group.
\sa palette(), setPalette()
*/
qt'QWidget::colorGroup() (./qt-2.1.0/src/kernel/qwidget.cpp:1998)
const QColorGroup &QWidget::colorGroup() const
{
if ( !isEnabled() )
return palette().disabled();
else if ( isActiveWindow() )
return palette().active();
else
return palette().inactive();
}
/*!
\fn const QPalette &QWidget::palette() const
Returns the widget palette.
As long as no special palette has been set, this is either a special
palette for the widget class, the parent's palette or - if this
widget is a toplevel widget - the default application palette.
\sa setPalette(), colorGroup(), QApplication::palette()
*/
/*! \enum QWidget::PropagationMode
\obsolete
This enum used to determine how fonts and palette changes are propagated to
children of a widget.
*/
/*!
Sets the widget palette to \e palette and informs all children about the change.
\sa QApplication::setPalette(), palette(), paletteChange(), unsetPalette(),
colorGroup()
*/
qt'QWidget::setPalette() (./qt-2.1.0/src/kernel/qwidget.cpp:2036)
void QWidget::setPalette( const QPalette &palette )
{
own_palette = TRUE;
if ( pal == palette )
return;
QPalette old = pal;
pal = palette;
setBackgroundFromMode();
paletteChange( old );
if ( children() ) {
QCustomEvent e( QEvent::ParentPaletteChange, 0 );
QObjectListIt it( *children() );
QWidget *w;
while( (w=(QWidget *)it.current()) != 0 ) {
++it;
if ( w->isWidgetType() )
QApplication::sendEvent( w, &e );
}
}
update();
}
/*!
Unsets the palette for this widget. The widget will use its natural
default palette from now on.
\sa setPalette()
*/
qt'QWidget::unsetPalette() (./qt-2.1.0/src/kernel/qwidget.cpp:2065)
void QWidget::unsetPalette()
{
if ( own_palette ) {
if ( !isTopLevel() && QApplication::palette( this ).isCopyOf( QApplication::palette() ) )
setPalette( parentWidget()->palette() );
else
setPalette( QApplication::palette( this ) );
own_palette = FALSE;
}
}
/*!\obsolete
Use setPalette( const QPalette& p ) instead.
*/
qt'QWidget::setPalette() (./qt-2.1.0/src/kernel/qwidget.cpp:2081)
void QWidget::setPalette( const QPalette &p, bool )
{
setPalette( p );
}
/*!
\fn void QWidget::paletteChange( const QPalette &oldPalette )
This virtual function is called from setPalette(). \e oldPalette is the
previous palette; you can get the new palette from palette().
Reimplement this function if your widget needs to know when its
palette changes. You will almost certainly need to call this
implementation of the function.
\sa setPalette(), palette()
*/
qt'QWidget::paletteChange() (./qt-2.1.0/src/kernel/qwidget.cpp:2099)
void QWidget::paletteChange( const QPalette & )
{
}
/*!
\fn QFont QWidget::font() const
Returns the font currently set for the widget.
fontInfo() tells you what font is actually being used.
As long as no special font has been set, this is either a special
font for the widget class, the parent's font or - if this widget is
a toplevel widget - the default application font.
\sa setFont(), fontInfo(), fontMetrics(), QApplication::font()
*/
/*!
Sets the font for the widget and informs all children about the
change.
The fontInfo() function reports the actual font that is being used by the
widget.
This code fragment sets a 12 point helvetica bold font:
\code
QFont f("Helvetica", 12, QFont::Bold);
setFont( f );
\endcode
\sa font(), fontChange(), fontInfo(), fontMetrics(), unsetFont()
*/
qt'QWidget::setFont() (./qt-2.1.0/src/kernel/qwidget.cpp:2135)
void QWidget::setFont( const QFont &font )
{
own_font = TRUE;
if ( fnt == font )
return;
QFont old = fnt;
fnt = font;
fnt.handle(); // force load font
fontChange( old );
if ( children() ) {
QCustomEvent e( QEvent::ParentFontChange, 0 );
QObjectListIt it( *children() );
QWidget *w;
while( (w=(QWidget *)it.current()) != 0 ) {
++it;
if ( w->isWidgetType() )
QApplication::sendEvent( w, &e );
}
}
if ( hasFocus() )
setFontSys();
}
/*!
Unsets the font for this widget. The widget will use its natural
default font from now on. This is either a special font for the
widget class, the parent's font or - if this widget is a toplevel
widget - the default application font.
\sa setFont()
*/
qt'QWidget::unsetFont() (./qt-2.1.0/src/kernel/qwidget.cpp:2166)
void QWidget::unsetFont()
{
if ( own_font ) {
if ( !isTopLevel() && QApplication::font( this ).isCopyOf( QApplication::font() ) )
setFont( parentWidget()->font() );
else
setFont( QApplication::font( this ) );
own_font = FALSE;
}
}
/*!\obsolete
Use setFont( const QFont& font) instead.
*/
qt'QWidget::setFont() (./qt-2.1.0/src/kernel/qwidget.cpp:2182)
void QWidget::setFont( const QFont &font, bool )
{
setFont( font );
}
/*!
\fn void QWidget::fontChange( const QFont &oldFont )
This virtual function is called from setFont(). \e oldFont is the
previous font; you can get the new font from font().
Reimplement this function if your widget needs to know when its font
changes. You will almost certainly need to update the widget using
update().
The default implementation updates the widget including its
geometry.
\sa setFont(), font(), update(), updateGeometry()
*/
qt'QWidget::fontChange() (./qt-2.1.0/src/kernel/qwidget.cpp:2203)
void QWidget::fontChange( const QFont & )
{
update();
updateGeometry();
}
/*!
\fn QFontMetrics QWidget::fontMetrics() const
Returns the font metrics for the widget's current font.
Equivalent to QFontMetrics(widget->font()).
\sa font(), fontInfo(), setFont()
*/
/*!
\fn QFontInfo QWidget::fontInfo() const
Returns the font info for the widget's current font.
Equivalent to QFontInto(widget->font()).
\sa font(), fontMetrics(), setFont()
*/
/*!
Returns the widget cursor. If no cursor has been set the parent
widget's cursor is returned.
\sa setCursor(), unsetCursor();
*/
qt'QWidget::cursor() (./qt-2.1.0/src/kernel/qwidget.cpp:2235)
const QCursor &QWidget::cursor() const
{
if ( testWState(WState_OwnCursor) )
return (extra && extra->curs)
? *extra->curs
: arrowCursor;
else
return isTopLevel() ? arrowCursor : parentWidget()->cursor();
}
/*!
Returns the widget caption. If no caption has been set (common for
child widgets), this functions returns a null string.
\sa setCaption(), icon(), iconText(), QString::isNull()
*/
qt'QWidget::caption() (./qt-2.1.0/src/kernel/qwidget.cpp:2253)
QString QWidget::caption() const
{
return extra && extra->topextra
? extra->topextra->caption
: QString::null;
}
/*!
Returns the widget icon pixmap, or null if no icon has been set.
\sa setIcon(), iconText(), caption()
*/
qt'QWidget::icon() (./qt-2.1.0/src/kernel/qwidget.cpp:2266)
const QPixmap *QWidget::icon() const
{
return extra && extra->topextra
? extra->topextra->icon
: 0;
}
/*!
Returns the widget icon text. If no icon text has been set (common for
child widgets), this functions returns a null string.
\sa setIconText(), icon(), caption(), QString::isNull()
*/
qt'QWidget::iconText() (./qt-2.1.0/src/kernel/qwidget.cpp:2280)
QString QWidget::iconText() const
{
return extra && extra->topextra
? extra->topextra->iconText
: QString::null;
}
/*!
\fn bool QWidget::hasMouseTracking() const
Returns TRUE if mouse tracking is enabled for this widget, or FALSE
if mouse tracking is disabled.
\sa setMouseTracking()
*/
/*!
\fn void QWidget::setMouseTracking( bool enable )
Enables mouse tracking if \e enable is TRUE, or disables it if \e enable
is FALSE.
If mouse tracking is disabled (default), this widget only receives
mouse move events when at least one mouse button is pressed down while
the mouse is being moved.
If mouse tracking is enabled, this widget receives mouse move events
even if no buttons are pressed down.
\sa hasMouseTracking(), mouseMoveEvent(),
QApplication::setGlobalMouseTracking()
*/
qt'QWidget::setMouseTracking() (./qt-2.1.0/src/kernel/qwidget.cpp:2315)
void QWidget::setMouseTracking( bool enable )
{
if ( enable )
setWState( WState_MouseTracking );
else
clearWState( WState_MouseTracking );
return;
}
#endif // _WS_X11_
/*! Sets this widget's focus proxy to \a w. If \a w is 0, this
function resets this widget to not have any focus proxy.
Some widgets, such as QComboBox, can "have focus," but create a
child widget to actually handle the focus. QComboBox, for example,
creates a QLineEdit.
setFocusProxy() sets the widget which will actually get focus when
"this widget" gets it. If there is a focus proxy, focusPolicy(),
setFocusPolicy(), setFocus() and hasFocus() all operate on the focus
proxy.
\sa focusProxy()
*/
qt'QWidget::setFocusProxy() (./qt-2.1.0/src/kernel/qwidget.cpp:2341)
void QWidget::setFocusProxy( QWidget * w )
{
if ( !w && !extra )
return;
createExtra();
if ( extra->focus_proxy ) {
disconnect( extra->focus_proxy, SIGNAL(destroyed()),
this, SLOT(focusProxyDestroyed()) );
extra->focus_proxy = 0;
}
if ( w ) {
setFocusPolicy( w->focusPolicy() );
connect( w, SIGNAL(destroyed()),
this, SLOT(focusProxyDestroyed()) );
}
extra->focus_proxy = w;
}
/*! Returns a pointer to the focus proxy, or 0 if there is no focus
proxy.
\sa setFocusProxy()
*/
qt'QWidget::focusProxy() (./qt-2.1.0/src/kernel/qwidget.cpp:2369)
QWidget * QWidget::focusProxy() const
{
return extra ? extra->focus_proxy : 0;
}
/*! Internal slot used to clean up if the focus proxy is destroyed.
\sa setFocusProxy()
*/
qt'QWidget::focusProxyDestroyed() (./qt-2.1.0/src/kernel/qwidget.cpp:2379)
void QWidget::focusProxyDestroyed()
{
if ( extra )
extra->focus_proxy = 0;
setFocusPolicy( NoFocus );
}
/*!
Returns TRUE if this widget (or its focus proxy) has the keyboard
input focus, otherwise FALSE.
Equivalent to <code>qApp->focusWidget() == this</code>.
\sa setFocus(), clearFocus(), setFocusPolicy(), QApplication::focusWidget()
*/
qt'QWidget::hasFocus() (./qt-2.1.0/src/kernel/qwidget.cpp:2396)
bool QWidget::hasFocus() const
{
const QWidget* w = this;
while ( w->focusProxy() )
w = w->focusProxy();
return qApp->focusWidget() == w;
}
/*!
Gives the keyboard input focus to the widget (or its focus proxy).
First, a \link focusOutEvent() focus out event\endlink is sent to the
focus widget (if any) to tell it that it is about to loose the
focus. Then a \link focusInEvent() focus in event\endlink is sent to
this widget to tell it that it just received the focus.
setFocus() gives focus to a widget regardless of its focus policy.
\warning If you call setFocus() in a function which may itself be
called from focusOutEvent() or focusInEvent(), you may see infinite
recursion.
\sa hasFocus(), clearFocus(), focusInEvent(), focusOutEvent(),
setFocusPolicy(), QApplication::focusWidget()
*/
qt'QWidget::setFocus() (./qt-2.1.0/src/kernel/qwidget.cpp:2422)
void QWidget::setFocus()
{
if ( !isEnabled() )
return;
if ( focusProxy() ) {
focusProxy()->setFocus();
return;
}
QFocusData * f = focusData(TRUE);
if ( f->it.current() == this && qApp->focusWidget() == this )
return;
// ### why do we do this twice?
f->it.toFirst();
while ( f->it.current() != this && !f->it.atLast() )
++f->it;
// at this point, the iterator should point to 'this'. if it
// does not, 'this' must not be in the list - an error, but
// perhaps possible. fix it.
if ( f->it.current() != this ) {
f->focusWidgets.append( this );
f->it.toLast();
}
f->it.toFirst();
while ( f->it.current() != this && !f->it.atLast() )
++f->it;
// at this point, the iterator should point to 'this'. if it
// does not, 'this' must not be in the list - an error, but
// perhaps possible. fix it.
if ( f->it.current() != this ) {
f->focusWidgets.append( this );
f->it.toLast();
}
if ( isActiveWindow() ) {
QWidget * prev = qApp->focus_widget;
qApp->focus_widget = this;
if ( prev != this ) {
if ( prev ) {
QFocusEvent out( QEvent::FocusOut );
QApplication::sendEvent( prev, &out );
}
QFocusEvent in( QEvent::FocusIn );
QApplication::sendEvent( this, &in );
}
}
}
/*!
Takes keyboard input focus from the widget.
If the widget has active focus, a \link focusOutEvent() focus out
event\endlink is sent to this widget to tell it that it is about to
loose the focus.
This widget must enable focus setting in order to get the keyboard input
focus, i.e. it must call setFocusPolicy().
\sa hasFocus(), setFocus(), focusInEvent(), focusOutEvent(),
setFocusPolicy(), QApplication::focusWidget()
*/
qt'QWidget::clearFocus() (./qt-2.1.0/src/kernel/qwidget.cpp:2489)
void QWidget::clearFocus()
{
if ( focusProxy() ) {
focusProxy()->clearFocus();
return;
} else {
QWidget* w = qApp->focusWidget();
if ( w && w->focusWidget() == this ) {
// clear active focus
qApp->focus_widget = 0;
QFocusEvent out( QEvent::FocusOut );
QApplication::sendEvent( w, &out );
}
}
}
/*!
Finds a new widget to give the keyboard focus to, as appropriate for
Tab/shift-Tab, and returns TRUE if is can find a new widget and
FALSE if it can't,
If \a next is true, this function searches "forwards", if \a next is
FALSE, "backwards".
Sometimes, you will want to reimplement this function. For example,
a web browser might reimplement it to move its "current active link"
forwards or backwards, and call QWidget::focusNextPrevChild() only
when it reaches the last/first.
Child widgets call focusNextPrevChild() on their parent widgets, and
only the top-level widget will thus make the choice of where to redirect
focus. By overriding this method for an object, you thus gain control
of focus traversal for all child widgets.
\sa focusData()
*/
qt'QWidget::focusNextPrevChild() (./qt-2.1.0/src/kernel/qwidget.cpp:2527)
bool QWidget::focusNextPrevChild( bool next )
{
QWidget* p = parentWidget();
if ( !testWFlags(WType_TopLevel) && p )
return p->focusNextPrevChild(next);
QFocusData *f = focusData( TRUE );
QWidget *startingPoint = f->it.current();
QWidget *candidate = 0;
QWidget *w = next ? f->focusWidgets.last() : f->focusWidgets.first();
do {
if ( w && w != startingPoint &&
( ( w->focusPolicy() & TabFocus ) == TabFocus )
&& !w->focusProxy() && w->isVisible() && w->isEnabled())
candidate = w;
w = next ? f->focusWidgets.prev() : f->focusWidgets.next();
} while( w && !(candidate && w==startingPoint) );
if ( !candidate )
return FALSE;
candidate->setFocus();
return TRUE;
}
/*!
Returns the focus widget in this widget's window. This
is not the same as QApplication::focusWidget(), which returns the
focus widget in the currently active window.
*/
qt'QWidget::focusWidget() (./qt-2.1.0/src/kernel/qwidget.cpp:2559)
QWidget *QWidget::focusWidget() const
{
QWidget *that = (QWidget *)this; // mutable
QFocusData *f = that->focusData( FALSE );
if ( f && f->focusWidgets.count() && f->it.current() == 0 )
f->it.toFirst();
return f ? f->it.current() : 0;
}
/*!
Returns a pointer to the focus data for this widget's top-level
widget.
Focus data always belongs to the top-level widget. The focus data
list contains all the widgets in this top-level widget that can
accept focus, in tab order. An iterator points to the current focus
widget (focusWidget() returns a pointer to this widget).
This information is useful for implementing advanced versions
of focusNextPrevChild().
*/
qt'QWidget::focusData() (./qt-2.1.0/src/kernel/qwidget.cpp:2581)
QFocusData * QWidget::focusData()
{
return focusData(TRUE);
}
/*!
Internal function which lets us not create it too.
*/
qt'QWidget::focusData() (./qt-2.1.0/src/kernel/qwidget.cpp:2589)
QFocusData * QWidget::focusData( bool create )
{
QWidget * tlw = topLevelWidget();
QWExtra * ed = tlw->extraData();
if ( !ed || !ed->topextra ) {
if ( !create )
return 0;
tlw->createTLExtra();
ed = tlw->extraData();
}
if ( create && !ed->topextra->focusData ) {
ed->topextra->focusData = new QFocusData;
}
return ed->topextra->focusData;
}
/*!
Enables key event compression, if \a enable is TRUE, and disables it
if \a enable is FALSE.
By default key compression is off, so widgets receive one key press
event for each key press (or more, since autorepeat is usually on).
If you turn it on and your program doesn't keep up with key input,
Qt tries to compress key events so that more than one character can
be processed in each event.
For example, a word processor widget might receive 2, 3 or more
characters in each QKeyEvent::text(), if the layout recalculation
takes too long for the CPU.
If a widget supports multiple character unicode input, it is always
safe to turn the compression on.
\sa QKeyEvent::text();
*/
qt'QWidget::setKeyCompression() (./qt-2.1.0/src/kernel/qwidget.cpp:2626)
void QWidget::setKeyCompression(bool compress)
{
if ( compress )
setWState( WState_CompressKeys );
else
clearWState( WState_CompressKeys );
}
/*!
Returns TRUE if this widget is in the active window, i.e. the
window that has keyboard focus.
When popup windows are visible, this function returns TRUE for both
the active window and the popup.
\sa setActiveWindow(), QApplication::activeWindow()
*/
qt'QWidget::isActiveWindow() (./qt-2.1.0/src/kernel/qwidget.cpp:2645)
bool QWidget::isActiveWindow() const
{
return (topLevelWidget() == qApp->activeWindow() )||
( isVisible() && topLevelWidget()->isPopup() );
}
/*!
Moves the \a second widget around the ring of focus widgets
so that keyboard focus moves from \a first widget to \a second
widget when Tab is pressed.
Note that since the tab order of the \e second widget is changed,
you should order a chain like this:
\code
setTabOrder(a, b ); // a to b
setTabOrder(b, c ); // a to b to c
setTabOrder(c, d ); // a to b to c to d
\endcode
not like this:
\code
setTabOrder(c, d); // c to d
setTabOrder(a, b); // a to b AND c to d
setTabOrder(b, c); // a to b to c, but not c to d
\endcode
If either \a first or \a second has a focus proxy, setTabOrder()
substitutes its/their proxies.
\sa setFocusPolicy(), setFocusProxy()
*/
qt'QWidget::setTabOrder() (./qt-2.1.0/src/kernel/qwidget.cpp:2681)
void QWidget::setTabOrder( QWidget* first, QWidget *second )
{
if ( !first || !second )
return;
while ( first->focusProxy() )
first = first->focusProxy();
while ( second->focusProxy() )
second = second->focusProxy();
QFocusData *f = first->focusData( TRUE );
bool focusThere = (f->it.current() == second );
f->focusWidgets.removeRef( second );
if ( f->focusWidgets.findRef( first ) >= 0 )
f->focusWidgets.insert( f->focusWidgets.at() + 1, second );
else
f->focusWidgets.append( second );
if ( focusThere ) { // reset iterator so tab will work appropriately
f->it.toFirst();
while( f->it.current() && f->it.current() != second )
++f->it;
}
}
/*!\internal
Moves the relevant subwidgets of this widget from the \a oldtlw's
tab chain to that of the new parent, if there's anything to move and
we're really moving
This function is called from QWidget::reparent() *after* the widget
has been reparented.
\sa reparent()
*/
qt'QWidget::reparentFocusWidgets() (./qt-2.1.0/src/kernel/qwidget.cpp:2717)
void QWidget::reparentFocusWidgets( QWidget * oldtlw )
{
if ( oldtlw == topLevelWidget() )
return; // nothing to do
QFocusData * from = oldtlw->topData()->focusData;
from->focusWidgets.first();
QFocusData * to;
to = focusData();
if ( from ) {
do {
QWidget * pw = from->focusWidgets.current();
while( pw && pw != this )
pw = pw->parentWidget();
if ( pw == this ) {
QWidget * w = from->focusWidgets.take();
if ( w == from->it.current() )
// probably best to clear keyboard focus, or
// the user might become rather confused
w->clearFocus();
if ( !isTopLevel() )
to->focusWidgets.append( w );
} else {
from->focusWidgets.next();
}
} while( from->focusWidgets.current() );
}
if ( to->focusWidgets.findRef(this) < 0 )
to->focusWidgets.append( this );
if ( !isTopLevel() && extra && extra->topextra && extra->topextra->focusData ) {
// this widget is no longer a top-level widget, so get rid
// of old focus data
delete extra->topextra->focusData;
extra->topextra->focusData = 0;
}
}
/*!
\fn void recreate( QWidget *parent, WFlags f, const QPoint & p, bool showIt )
\obsolete
This method is provided to aid porting to Qt 2.0. The function is
renamed to reparent() in 2.0, and we hope the FAQs about it will
stop.
*/
/*!
Returns the size of the window system frame (for top level widgets).
*/
qt'QWidget::frameSize() (./qt-2.1.0/src/kernel/qwidget.cpp:2772)
QSize QWidget::frameSize() const
{
return extra && extra->topextra
? extra->topextra->fsize
: crect.size();
}
/*!
\internal
Sets the frame rectangle and recomputes the client rectangle.
The frame rectangle is the geometry of this widget including any
decorative borders, in its parent's coordinate system.
The client rectangle is the geometry of just this widget in its
parent's coordinate system.
*/
qt'QWidget::setFRect() (./qt-2.1.0/src/kernel/qwidget.cpp:2790)
void QWidget::setFRect( const QRect &r )
{
if ( extra && extra->topextra ) {
QRect frect = frameGeometry();
crect.setLeft( crect.left() + r.left() - frect.left() );
crect.setTop( crect.top() + r.top() - frect.top() );
crect.setRight( crect.right() + r.right() - frect.right() );
crect.setBottom( crect.bottom() + r.bottom() - frect.bottom() );
fpos = r.topLeft();
extra->topextra->fsize = r.size();
} else {
// One rect is both the same.
fpos = r.topLeft();
crect = r;
}
}
/*!
\internal
Sets the client rectangle and recomputes the frame rectangle.
The client rectangle is the geometry of just this widget in its
parent's coordinate system.
The frame rectangle is the geometry of this widget including any
decorative borders, in its parent's coordinate system.
*/
qt'QWidget::setCRect() (./qt-2.1.0/src/kernel/qwidget.cpp:2818)
void QWidget::setCRect( const QRect &r )
{
if ( extra && extra->topextra ) {
QRect frect = frameGeometry();
frect.setLeft( frect.left() + r.left() - crect.left() );
frect.setTop( frect.top() + r.top() - crect.top() );
frect.setRight( frect.right() + r.right() - crect.right() );
frect.setBottom( frect.bottom() + r.bottom() - crect.bottom() );
fpos = frect.topLeft();
extra->topextra->fsize = frect.size();
} else {
// One rect is both the same.
fpos = r.topLeft();
}
crect = r;
}
/*!
\overload void QWidget::move( const QPoint & )
*/
/*!
Moves the widget to the position \e (x,y) relative to the parent widget and
including the window frame.
If the widget is visible, it receives a \link moveEvent() move
event\endlink immediately. If the widget is not shown yet, it is
guaranteed to receive an event before it actually becomes visible.
This function is virtual, and all other overloaded move()
implementations call it.
\warning If you call move() or setGeometry() from moveEvent(), you
may see infinite recursion.
See the \link geometry.html Window Geometry documentation\endlink
for an overview of geometry issues with top-level widgets.
\sa pos(), resize(), setGeometry(), moveEvent()
*/
qt'QWidget::move() (./qt-2.1.0/src/kernel/qwidget.cpp:2860)
void QWidget::move( int x, int y )
{
internalSetGeometry( x + geometry().x() - QWidget::x(),
y + geometry().y() - QWidget::y(),
width(), height(), TRUE );
}
/*!
\overload void QWidget::resize( const QSize & )
*/
/*!
Resizes the widget to size \e w by \e h pixels.
If the widget is visible, it receives a \link resizeEvent() resize
event\endlink immediately. If the widget is not shown yet, it is
guaranteed to receive an event before it actually becomes visible.
The size is adjusted if it is outside the \link setMinimumSize()
minimum\endlink or \link setMaximumSize() maximum\endlink widget size.
This function is virtual, and all other overloaded resize()
implementations call it.
\warning If you call resize() or setGeometry() from resizeEvent(),
you may see infinite recursion.
\sa size(), move(), setGeometry(), resizeEvent(),
minimumSize(), maximumSize()
*/
qt'QWidget::resize() (./qt-2.1.0/src/kernel/qwidget.cpp:2892)
void QWidget::resize( int w, int h )
{
internalSetGeometry( geometry().x(), geometry().y(), w, h, FALSE );
setWState( WState_Resized );
}
/*!
\overload void QWidget::setGeometry( const QRect & )
*/
/*!
Sets the widget geometry to \e w by \e h, positioned at \e x,y in its
parent widget.
If the widget is visible, it receives a \link moveEvent() move
event\endlink and/or \link resizeEvent() resize event \endlink
immediately. If the widget is not shown yet, it is guaranteed to
receive appropriate events before it actually becomes visible.
The size is adjusted if it is outside the \link setMinimumSize()
minimum\endlink or \link setMaximumSize() maximum\endlink widget size.
This function is virtual, and all other overloaded setGeometry()
implementations call it.
\warning If you call setGeometry() from resizeEvent() or moveEvent(),
you may see infinite recursion.
\sa geometry(), move(), resize(), moveEvent(), resizeEvent(),
minimumSize(), maximumSize()
*/
qt'QWidget::setGeometry() (./qt-2.1.0/src/kernel/qwidget.cpp:2925)
void QWidget::setGeometry( int x, int y, int w, int h )
{
internalSetGeometry( x, y, w, h, TRUE );
setWState( WState_Resized );
}
/*!
\fn bool QWidget::isFocusEnabled() const
Returns TRUE if the widget accepts keyboard focus, or FALSE if it does
not.
Keyboard focus is initially disabled (i.e. focusPolicy() ==
\c QWidget::NoFocus).
You must enable keyboard focus for a widget if it processes keyboard
events. This is normally done from the widget's constructor. For
instance, the QLineEdit constructor calls
setFocusPolicy(\c QWidget::StrongFocus).
\sa setFocusPolicy(), focusInEvent(), focusOutEvent(), keyPressEvent(),
keyReleaseEvent(), isEnabled()
*/
/*! \enum QWidget::FocusPolicy
This enum type defines the various policies a widget can have with
respect to acquiring keyboard focus.
The \e policy can be:
<ul>
<li> \c QWidget::TabFocus - the widget accepts focus by tabbing.
<li> \c QWidget::ClickFocus - the widget accepts focus by clicking.
<li> \c QWidget::StrongFocus - the widget accepts focus by both tabbing
and clicking.
<li> \c QWidget::WheelFocus - like StrongFocus plus the widget accepts
focus by using the mouse wheel.
<li> \c QWidget::NoFocus - the widget does not accept focus.
</ul>
*/
/*!
\fn QWidget::FocusPolicy QWidget::focusPolicy() const
Returns \c QWidget::TabFocus if the widget accepts focus by tabbing, \c
QWidget::ClickFocus if the widget accepts focus by clicking, \c
QWidget::StrongFocus if it accepts both and \c QWidget::NoFocus if it
does not accept focus at all.
\sa isFocusEnabled(), setFocusPolicy(), focusInEvent(), focusOutEvent(),
keyPressEvent(), keyReleaseEvent(), isEnabled()
*/
/*!
Enables or disables the keyboard focus for the widget.
The keyboard focus is initially disabled (i.e. \a policy ==
\c QWidget::NoFocus).
You must enable keyboard focus for a widget if it processes keyboard
events. This is normally done from the widget's constructor. For
instance, the QLineEdit constructor calls
setFocusPolicy(\c QWidget::StrongFocus).
As a special case to support applications not utilizing focus,
\link isTopLevel() Top-level widgets \endlink that have
NoFocus policy will receive focus events and
gain keyboard events.
\sa isFocusEnabled(), focusInEvent(), focusOutEvent(), keyPressEvent(),
keyReleaseEvent(), isEnabled()
*/
qt'QWidget::setFocusPolicy() (./qt-2.1.0/src/kernel/qwidget.cpp:2999)
void QWidget::setFocusPolicy( FocusPolicy policy )
{
if ( focusProxy() )
focusProxy()->setFocusPolicy( policy );
if ( policy ) {
QFocusData * f = focusData( TRUE );
if ( f->focusWidgets.findRef( this ) < 0 )
f->focusWidgets.append( this );
}
focus_policy = (uint)policy;
}
/*!
\fn bool QWidget::isUpdatesEnabled() const
Returns TRUE if updates are enabled, otherwise FALSE.
\sa setUpdatesEnabled()
*/
/*!
Enables widget updates if \e enable is TRUE, or disables widget updates
if \e enable is FALSE.
Calling update() and repaint() has no effect if updates are disabled.
Paint events from the window system are processed as normally even if
updates are disabled.
This function is normally used to disable updates for a short period of
time, for instance to avoid screen flicker during large changes.
Example:
\code
setUpdatesEnabled( FALSE );
bigVisualChanges();
setUpdatesEnabled( TRUE );
repaint();
\endcode
\sa isUpdatesEnabled(), update(), repaint(), paintEvent()
*/
qt'QWidget::setUpdatesEnabled() (./qt-2.1.0/src/kernel/qwidget.cpp:3040)
void QWidget::setUpdatesEnabled( bool enable )
{
if ( enable )
clearWState( WState_BlockUpdates );
else
setWState( WState_BlockUpdates );
}
/*
Returns TRUE if there's no non-withdrawn top level window left
(except the desktop, dialogs or popups). This is an internal
function used by QWidget::close() to decide whether to emit
QApplication::lastWindowClosed() or not.
*/
qt'QWidget::show() (./qt-2.1.0/src/kernel/qwidget.cpp:3092)
void QWidget::show()
{
bool sendLayoutHint = !isTopLevel() && testWState( WState_ForceHide );
clearWState( WState_ForceHide );
if ( testWState(WState_Visible) )
return; // nothing to do
if ( !isTopLevel() && !parentWidget()->isVisibleTo( 0 ) ){
// we should become visible, but our parents are explicitely
// hidden. Don' worry, since we cleared the ForceHide flag,
// our immediate parent will call show() on us again during
// his own processing of show().
if ( sendLayoutHint ) {
QCustomEvent e( QEvent::ShowToParent, 0 );
QApplication::sendEvent( this, &e );
}
return;
}
QApplication::sendPostedEvents( this, QEvent::ChildInserted );
if ( isTopLevel() && !testWState( WState_Resized ) ) {
// do this before sending the posted resize events. Otherwise
// the layout would catch the resize event and may expand the
// minimum size.
QSize s = sizeHint();
QSizePolicy::ExpandData exp;
if ( layout() ) {
if ( layout()->hasHeightForWidth() )
s.setHeight( layout()->totalHeightForWidth( s.width() ) );
exp = layout()->expanding();
} else {
if ( sizePolicy().hasHeightForWidth() )
s.setHeight( heightForWidth( s.width() ) );
exp = sizePolicy().expanding();
}
if ( exp & QSizePolicy::Horizontal )
s.setWidth( QMAX( s.width(), 200 ) );
if ( exp & QSizePolicy::Vertical )
s.setHeight( QMAX( s.height(), 150 ) );
QWidget * d = QApplication::desktop();
s.setWidth( QMIN( s.width(), d->width()*2/3 ) );
s.setHeight( QMIN( s.height(), d->height()*2/3 ) );
if ( !s.isEmpty() )
resize( s );
}
QApplication::sendPostedEvents( this, QEvent::Move );
QApplication::sendPostedEvents( this, QEvent::Resize );
setWState( WState_Visible );
if ( parentWidget() )
QApplication::sendPostedEvents( parentWidget(),
QEvent::ChildInserted );
if ( extra ) {
int w = crect.width();
int h = crect.height();
if ( w < extra->minw || h < extra->minh ||
w > extra->maxw || h > extra->maxh ) {
w = QMAX( extra->minw, QMIN( w, extra->maxw ));
h = QMAX( extra->minh, QMIN( h, extra->maxh ));
resize( w, h ); // deferred resize
}
}
if ( testWFlags(WStyle_Tool) || isPopup() ) {
raise();
}
if ( testWFlags(WType_TopLevel) && !isPopup() ) {
while ( QApplication::activePopupWidget() )
QApplication::activePopupWidget()->hide();
}
if ( !testWState(WState_Polished) )
polish();
if ( children() ) {
QObjectListIt it(*children());
register QObject *object;
QWidget *widget;
while ( it ) { // show all widget children
object = it.current(); // (except popups and other toplevels)
++it;
if ( object->isWidgetType() ) {
widget = (QWidget*)object;
if ( !widget->testWState(WState_ForceHide) && !widget->isTopLevel() )
widget->show();
}
}
}
if ( !isTopLevel() && !parentWidget()->isVisible() ) {
// we should become visible, but somehow our parent is not
// visible, so we can't do that. Since it is not explicitely
// hidden (that we checked above with isVisibleTo(0) ), our
// window is not withdrawn, but may for example be iconfied or
// on another virtual desktop. Therefore we have to prepare
// for simply receiving a show event without show() beeing
// called again (see the call to sendShowEventsToChildren() in
// qapplication).
showWindow();
clearWState( WState_Visible );
if ( sendLayoutHint ) {
QCustomEvent e( QEvent::ShowToParent, 0 );
QApplication::sendEvent( this, &e );
}
} else {
QShowEvent e(FALSE);
QApplication::sendEvent( this, &e );
if ( testWFlags(WType_Modal) ) {
// qt_enter_modal *before* show, otherwise the initial
// stacking might be wrong
qt_enter_modal( this );
}
showWindow();
if ( testWFlags(WType_Popup) )
qApp->openPopup( this );
}
if ( sendLayoutHint )
QApplication::postEvent( parentWidget(),
new QEvent( QEvent::LayoutHint) );
}
/*!
Hides the widget.
You almost never have to reimplement this function. If you need to
do something after a widget is hidden, use hideEvent() instead.
\sa hideEvent(), show(), showMinimized(), isVisible(), close()
*/
qt'QWidget::hide() (./qt-2.1.0/src/kernel/qwidget.cpp:3234)
void QWidget::hide()
{
if ( testWState(WState_ForceHide) )
return;
setWState( WState_ForceHide );
if ( testWFlags(WType_Popup) )
qApp->closePopup( this );
if ( isTopLevel() && !isPopup() && parentWidget() && isActiveWindow() )
parentWidget()->setActiveWindow(); // Activate parent
hideWindow();
if ( !testWState(WState_Visible) ) {
QCustomEvent e( QEvent::HideToParent, 0 );
QApplication::sendEvent( this, &e );
return;
}
clearWState( WState_Visible );
// next bit tries to move the focus if the focus widget is now
// hidden.
if ( qApp && qApp->focusWidget() == this )
focusNextPrevChild( TRUE );
QHideEvent e(FALSE);
QApplication::sendEvent( this, &e );
// post layout hint for non toplevels. The parent widget check is
// necessary since the function is called in the destructor
if ( !isTopLevel() && parentWidget() )
QApplication::postEvent( parentWidget(),
new QEvent( QEvent::LayoutHint) );
sendHideEventsToChildren( FALSE );
if ( testWFlags(WType_Modal) )
qt_leave_modal( this );
}
qt'QWidget::sendShowEventsToChildren() (./qt-2.1.0/src/kernel/qwidget.cpp:3276)
void QWidget::sendShowEventsToChildren( bool spontaneous )
{
if ( children() ) {
QObjectListIt it(*children());
register QObject *object;
QWidget *widget;
while ( it ) {
object = it.current();
++it;
if ( object->isWidgetType() ) {
widget = (QWidget*)object;
if ( !widget->isTopLevel() && !widget->isVisible() && !widget->testWState(WState_ForceHide) ) {
widget->setWState( WState_Visible );
widget->sendShowEventsToChildren( spontaneous );
QShowEvent e( spontaneous );
QApplication::sendEvent( widget, &e );
}
}
}
}
}
qt'QWidget::sendHideEventsToChildren() (./qt-2.1.0/src/kernel/qwidget.cpp:3298)
void QWidget::sendHideEventsToChildren( bool spontaneous )
{
if ( children() ) {
QObjectListIt it(*children());
register QObject *object;
QWidget *widget;
while ( it ) {
object = it.current();
++it;
if ( object->isWidgetType() ) {
widget = (QWidget*)object;
if ( !widget->isTopLevel() && widget->isVisible() ) {
widget->clearWState( WState_Visible );
widget->sendHideEventsToChildren( spontaneous );
QHideEvent e( spontaneous );
QApplication::sendEvent( widget, &e );
}
}
}
}
}
/*!
Delayed initialization of a widget.
This function will be called \e after a widget has been fully created
and \e before it is shown the very first time.
Polishing is useful for final initialization depending on an
instantiated widget. This is something a constructor cannot
guarantee since the initialization of the subclasses might not be
finished.
After this function, the wiget has a proper font and palette and
QApplication::polish() has been called.
Remember to call QWidget's implementation when reimplementing this
function.
\sa constPolish(), QApplication::polish()
*/
qt'QWidget::polish() (./qt-2.1.0/src/kernel/qwidget.cpp:3341)
void QWidget::polish()
{
if ( !testWState(WState_Polished) ) {
if ( !own_font && !QApplication::font( this ).isCopyOf( QApplication::font() ) ) {
setFont( QApplication::font( this ) );
own_font = FALSE;
}
if ( !own_palette && !QApplication::palette( this ).isCopyOf( QApplication::palette() ) ) {
setPalette( QApplication::palette( this ) );
own_palette = FALSE;
}
setWState(WState_Polished);
qApp->polish( this );
QApplication::sendPostedEvents( this, QEvent::ChildInserted );
}
}
/*!
\fn void QWidget::constPolish() const
Ensures that the widget is properly initialized by calling polish().
Call constPolish() from functions like sizeHint() that depends on
the widget being initialized, and that may be called before show().
\warning Do not call constPolish() on a widget from inside that
widget's constructor.
\sa polish()
*/
/*!
Closes this widget. Returns TRUE if the widget was closed, otherwise
FALSE.
If \a alsoDelete is TRUE or the widget has the \c WDestructiveClose
widget flag, the widget is also deleted. The widget can prevent
itself from being closed by rejecting the QCloseEvent it gets.
The QApplication::lastWindowClosed() signal is emitted when the last
visible top level widget is closed.
Note that closing the \l QApplication::mainWidget() terminates the
application.
\sa closeEvent(), QCloseEvent, hide(), QApplication::quit(),
QApplication::setMainWidget(), QApplication::lastWindowClosed()
*/
qt'QWidget::close() (./qt-2.1.0/src/kernel/qwidget.cpp:3392)
bool QWidget::close( bool alsoDelete )
{
WId id = winId();
bool isMain = qApp->mainWidget() == this;
bool checkLastWindowClosed = isTopLevel() && !isPopup() &&
!testWFlags(WStyle_Dialog);
QCloseEvent e;
QApplication::sendEvent( this, &e );
bool accept = e.isAccepted();
if ( !QWidget::find(id) ) { // widget was deleted
accept = TRUE;
} else {
if ( accept ) {
hide();
if ( alsoDelete || testWFlags(WDestructiveClose) )
delete this;
}
}
if ( accept ) { // last window closed?
if ( checkLastWindowClosed
&& qApp->receivers(SIGNAL(lastWindowClosed()))
&& noMoreToplevels() )
emit qApp->lastWindowClosed();
if ( isMain )
qApp->quit();
}
return accept;
}
/*!
\fn bool QWidget::close()
Closes this widget. Returns TRUE if the widget was closed, otherwise
FALSE.
First it sends the widget a QCloseEvent. The widget is \link hide()
hidden\endlink if it \link QCloseEvent::accept() accepts\endlink the
close event. The default implementation of QWidget::closeEvent()
accepts the close event.
The QApplication::lastWindowClosed() signal is emitted when the last
visible top level widget is closed.
\sa close(bool)
*/
/*!
\fn bool QWidget::isVisible() const
Returns TRUE if the widget itself is visible, or else FALSE.
Calling show() sets the widget to visible status if all its parent
widgets up to the toplevel widget are visible. If an ancestor is not
visible, the widget won't become visible until all its ancestors are
shown.
Calling hide() hides a widget explicitly. An explicitly hidden
widget will never become visible, even if all its ancestors become
visible.
Iconified top-level widgets also have hidden status, as well as
having isMinimized() return TRUE.
This function returns TRUE if the widget currently is obscured by
other windows on the screen, but would be visible if moved.
\sa show(), hide(), isVisibleTo(), isMinimized()
*/
/*!
Returns TRUE if this widget would become visible if \a ancestor is
shown.
This is the case if neither the widget itself nor every parent up to
but excluding \a ancestor has been explicitely hidden.
This function returns TRUE if the widget it is obscured by other
windows on the screen, but would be visible if moved.
isVisibleTo(0) is equivalent to isVisible().
\sa show() hide() isVisible()
*/
qt'QWidget::isVisibleTo() (./qt-2.1.0/src/kernel/qwidget.cpp:3477)
bool QWidget::isVisibleTo(QWidget* ancestor) const
{
const QWidget * w = this;
while ( w
&& !w->testWState( WState_ForceHide )
&& !w->isTopLevel()
&& w->parentWidget()
&& w->parentWidget()!=ancestor )
w = w->parentWidget();
return !w->testWState( WState_ForceHide );
}
/*!\obsolete
This function is deprecated. It is equivalent to isVisible()
\sa show(), hide(), isVisible()
*/
qt'QWidget::isVisibleToTLW() (./qt-2.1.0/src/kernel/qwidget.cpp:3497)
bool QWidget::isVisibleToTLW() const
{
return isVisible();
}
/*!
Returns the currently visible rectangle of the widget. This function
is in particular useful to optimize immediate repainting of a
windget. Typical usage is
\code
repaint( w->visibleRect() );
\endcode
or
\code
repaint( w->visibleRect(), FALSE );
\endcode
If nothing is visible, the rectangle returned is empty.
*/
qt'QWidget::visibleRect() (./qt-2.1.0/src/kernel/qwidget.cpp:3517)
QRect QWidget::visibleRect() const
{
QRect r = rect();
const QWidget * w = this;
int ox = 0;
int oy = 0;
while ( w
&& w->isVisible()
&& !w->isTopLevel()
&& w->parentWidget() ) {
ox -= w->x();
oy -= w->y();
w = w->parentWidget();
r = r.intersect( QRect( ox, oy, w->width(), w->height() ) );
}
if ( !w->isVisible() )
return QRect();
else
return r;
}
/*!
Adjusts the size of the widget to fit the contents.
Uses sizeHint() if valid (i.e if the size hint's width and height are
equal to or greater than 0), otherwise sets the size to the children
rectangle (the union of all child widget geometries).
\sa sizeHint(), childrenRect()
*/
qt'QWidget::adjustSize() (./qt-2.1.0/src/kernel/qwidget.cpp:3549)
void QWidget::adjustSize()
{
if ( !testWState(WState_Polished) )
polish();
QSize s = sizeHint();
if ( s.isValid() ) {
resize( s );
return;
}
QRect r = childrenRect(); // get children rectangle
if ( r.isNull() ) // probably no widgets
return;
resize( r.width()+2*r.x(), r.height()+2*r.y() );
}
/*!
Returns a recommended size for the widget, or an invalid size if
no size is recommended.
The default implementation returns an invalid size if there is no layout
for this widget, the layout's preferred size otherwise.
\sa QSize::isValid(), minimumSizeHint(), sizePolicy(), setMinimumSize(), updateGeometry()
*/
qt'QWidget::sizeHint() (./qt-2.1.0/src/kernel/qwidget.cpp:3575)
QSize QWidget::sizeHint() const
{
if ( layout() )
return layout()->totalSizeHint();
constPolish();
return QSize( -1, -1 );
}
/*!
Returns a recommended minimum size for the widget, or an invalid
size if no minimum size is recommended.
The default implementation returns an invalid size if there is no layout
for this widget, the layout's minimum size otherwise.
\sa QSize::isValid(), resize(), setMinimumSize(), sizePolicy()
*/
qt'QWidget::minimumSizeHint() (./qt-2.1.0/src/kernel/qwidget.cpp:3596)
QSize QWidget::minimumSizeHint() const
{
if ( layout() )
return layout()->totalMinimumSize();
constPolish();
return QSize( -1, -1 );
}
/*!
\fn QWidget *QWidget::parentWidget() const
Returns a pointer to the parent of this widget, or a null pointer if
it does not have any parent widget.
*/
/*!
\fn bool QWidget::testWFlags( WFlags n ) const
Returns TRUE if any of the widget flags in \e n are set. The
widget flags are listed in qnamespace.h, and are strictly for
internal use.
*/
/*!
\fn bool QWidget::testWState (uint n) const
\internal
Tests the widget states \a n, returning TRUE if any are set.
*/
/*!
\fn uint QWidget::getWState () const
\internal
Returns the current widget state.
*/
/*!
\fn void QWidget::clearWState (uint n)
\internal
Clears the widgets states \a n.
*/
/*!
\fn void QWidget::setWState(uint n)
\internal
Sets the widgets states \a n.
*/
/*****************************************************************************
QWidget event handling
*****************************************************************************/
/*!
This is the main event handler. You may reimplement this function
in a subclass, but we recommend using one of the specialized event
handlers instead.
The main event handler first passes an event through all \link
QObject::installEventFilter() event filters\endlink that have been
installed. If none of the filters intercept the event, it calls one
of the specialized event handlers.
Key press/release events are treated differently from other events.
event() checks for Tab and shift-Tab and tries to move the focus
appropriately. If there is no widget to move the focus to (or the
key press is not Tab or shift-Tab), event() calls keyPressEvent().
This function returns TRUE if it is able to pass the event over to
someone, or FALSE if nobody wanted the event.
\sa closeEvent(), focusInEvent(), focusOutEvent(), enterEvent(),
keyPressEvent(), keyReleaseEvent(), leaveEvent(),
mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(),
mouseReleaseEvent(), moveEvent(), paintEvent(),
resizeEvent(), QObject::event(), QObject::timerEvent()
*/
qt'QWidget::event() (./qt-2.1.0/src/kernel/qwidget.cpp:3672)
bool QWidget::event( QEvent *e )
{
if ( eventFilters ) { // try filters
if ( activate_filters(e) ) // stopped by a filter
return TRUE;
}
switch ( e->type() ) {
case QEvent::Timer:
timerEvent( (QTimerEvent*)e );
break;
case QEvent::MouseMove:
mouseMoveEvent( (QMouseEvent*)e );
break;
case QEvent::MouseButtonPress:
mousePressEvent( (QMouseEvent*)e );
break;
case QEvent::MouseButtonRelease:
mouseReleaseEvent( (QMouseEvent*)e );
break;
case QEvent::MouseButtonDblClick:
mouseDoubleClickEvent( (QMouseEvent*)e );
break;
case QEvent::Wheel:
wheelEvent( (QWheelEvent*)e );
if ( ! ((QWheelEvent*)e)->isAccepted() )
return FALSE;
break;
case QEvent::KeyPress: {
QKeyEvent *k = (QKeyEvent *)e;
bool res = FALSE;
if ( k->key() == Key_Backtab ||
(k->key() == Key_Tab &&
(k->state() & ShiftButton)) ) {
QFocusEvent::setReason( QFocusEvent::Tab );
res = focusNextPrevChild( FALSE );
QFocusEvent::resetReason();
} else if ( k->key() == Key_Tab ) {
QFocusEvent::setReason( QFocusEvent::Tab );
res = focusNextPrevChild( TRUE );
QFocusEvent::resetReason();
}
if ( res )
break;
QWidget *w = this;
while ( w ) {
w->keyPressEvent( k );
if ( k->isAccepted() || w->isTopLevel() )
break;
w = w->parentWidget();
k->accept();
}
}
break;
case QEvent::KeyRelease: {
QKeyEvent *k = (QKeyEvent *)e;
QWidget *w = this;
while ( w ) {
k->accept();
w->keyReleaseEvent( k );
if ( k->isAccepted() || w->isTopLevel() )
break;
w = w->parentWidget();
}
}
break;
case QEvent::FocusIn:
setFontSys();
focusInEvent( (QFocusEvent*)e );
break;
case QEvent::FocusOut:
focusOutEvent( (QFocusEvent*)e );
break;
case QEvent::Enter:
enterEvent( e );
break;
case QEvent::Leave:
leaveEvent( e );
break;
case QEvent::Paint:
// At this point the event has to be delivered, regardless
// whether the widget isVisible() or not because it
// already went through the filters
paintEvent( (QPaintEvent*)e );
break;
case QEvent::Move:
moveEvent( (QMoveEvent*)e );
break;
case QEvent::Resize:
resizeEvent( (QResizeEvent*)e );
break;
case QEvent::Close: {
QCloseEvent *c = (QCloseEvent *)e;
closeEvent( c );
if ( !c->isAccepted() )
return FALSE;
}
break;
case QEvent::Drop:
dropEvent( (QDropEvent*) e);
break;
case QEvent::DragEnter:
dragEnterEvent( (QDragEnterEvent*) e);
break;
case QEvent::DragMove:
dragMoveEvent( (QDragMoveEvent*) e);
break;
case QEvent::DragLeave:
dragLeaveEvent( (QDragLeaveEvent*) e);
break;
case QEvent::Show:
showEvent( (QShowEvent*) e);
break;
case QEvent::Hide:
hideEvent( (QHideEvent*) e);
break;
case QEvent::ChildInserted:
case QEvent::ChildRemoved:
childEvent( (QChildEvent*) e);
break;
case QEvent::ParentFontChange:
if ( isTopLevel() )
break;
// FALL THROUGH
case QEvent::ApplicationFontChange:
if ( !own_font && !isDesktop() ) {
if ( !isTopLevel() && QApplication::font( this ).isCopyOf( QApplication::font() ) )
setFont( parentWidget()->font() );
else
setFont( QApplication::font( this ) );
own_font = FALSE;
}
case QEvent::ParentPaletteChange:
if ( isTopLevel() )
break;
// FALL THROUGH
case QEvent::ApplicationPaletteChange:
if ( !own_palette && !isDesktop() ) {
if ( !isTopLevel() && QApplication::palette( this ).isCopyOf( QApplication::palette() ) )
setPalette( parentWidget()->palette() );
else
setPalette( QApplication::palette( this ) );
own_palette = FALSE;
}
break;
default:
if ( e->type() >= QEvent::User ) {
customEvent( (QCustomEvent*) e );
return TRUE;
}
return FALSE;
}
return TRUE;
}
/*!
This event handler can be reimplemented in a subclass to receive
mouse move events for the widget.
If mouse tracking is switched off, mouse move events only occur if a
mouse button is down while the mouse is being moved. If mouse
tracking is switched on, mouse move events occur even if no mouse
button is down.
QMouseEvent::pos() reports the position of the mouse cursor, relative to
this widget. For press and release events, the position is usually
the same as the position of the last mouse move event, but it might be
different if the user moves and clicks the mouse fast. This is
a feature of the underlying window system, not Qt.
\sa setMouseTracking(), mousePressEvent(), mouseReleaseEvent(),
mouseDoubleClickEvent(), event(), QMouseEvent
*/
qt'QWidget::mouseMoveEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:3863)
void QWidget::mouseMoveEvent( QMouseEvent * )
{
}
/*!
This event handler can be reimplemented in a subclass to receive
mouse press events for the widget.
If you create new widgets in the mousePressEvent() the
mouseReleaseEvent() may not end up where you expect, depending on the
underlying window system (or X11 window manager), the widgets'
location and maybe more.
The default implementation implements the closing of popup widgets
when you click outside the window. For other widget types it does
nothing.
\sa mouseReleaseEvent(), mouseDoubleClickEvent(),
mouseMoveEvent(), event(), QMouseEvent
*/
qt'QWidget::mousePressEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:3884)
void QWidget::mousePressEvent( QMouseEvent *e )
{
if ( isPopup() ) {
QWidget* w;
while ( (w = qApp->activePopupWidget() ) && w != this ){
w->close();
if (qApp->activePopupWidget() == w) // widget does not want to dissappear
w->hide(); // hide at least
}
if (!rect().contains(e->pos()) ){
close();
}
}
}
/*!
This event handler can be reimplemented in a subclass to receive
mouse release events for the widget.
\sa mouseReleaseEvent(), mouseDoubleClickEvent(),
mouseMoveEvent(), event(), QMouseEvent
*/
qt'QWidget::mouseReleaseEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:3907)
void QWidget::mouseReleaseEvent( QMouseEvent * )
{
}
/*!
This event handler can be reimplemented in a subclass to receive
mouse double click events for the widget.
The default implementation generates a normal mouse press event.
Note that the widgets gets a mousePressEvent() and a mouseReleaseEvent()
before the mouseDoubleClickEvent().
\sa mousePressEvent(), mouseReleaseEvent()
mouseMoveEvent(), event(), QMouseEvent
*/
qt'QWidget::mouseDoubleClickEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:3924)
void QWidget::mouseDoubleClickEvent( QMouseEvent *e )
{
mousePressEvent( e ); // try mouse press event
}
/*!
This event handler can be reimplemented in a subclass to receive
wheel events for the widget.
If you reimplement this handler, it is very important that you \link
QWheelEvent ignore()\endlink the event if you do not handle it, so
that the widget's parent can interpret it.
The default implementation ignores the event.
\sa QWheelEvent::ignore(), QWheelEvent::accept(),
event(), QWheelEvent
*/
qt'QWidget::wheelEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:3944)
void QWidget::wheelEvent( QWheelEvent *e )
{
e->ignore();
}
/*!
This event handler can be reimplemented in a subclass to receive key
press events for the widget.
A widget must call setFocusPolicy() to accept focus initially and
have focus in order to receive a key press event.
If you reimplement this handler, it is very important that you
ignore() the event if you do not understand it, so that the widget's
parent can interpret it.
The default implementation closes popup widgets if you hit
escape. Otherwise the event is ignored.
As a special case to support applications not utilizing focus,
\link isTopLevel() Top-level widgets \endlink that have
NoFocus policy will receive keyboard events.
\sa keyReleaseEvent(), QKeyEvent::ignore(), setFocusPolicy(),
focusInEvent(), focusOutEvent(), event(), QKeyEvent
*/
qt'QWidget::keyPressEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:3972)
void QWidget::keyPressEvent( QKeyEvent *e )
{
if ( isPopup() && e->key() == Key_Escape ) {
e->accept();
close();
} else {
e->ignore();
}
}
/*!
This event handler can be reimplemented in a subclass to receive
key release events for the widget.
A widget must \link setFocusPolicy() accept focus\endlink initially
and \link hasFocus() have focus\endlink in order to receive a key
release event.
If you reimplement this handler, it is very important that you \link
QKeyEvent ignore()\endlink the release if you do not understand it,
so that the widget's parent can interpret it.
The default implementation ignores the event.
\sa keyPressEvent(), QKeyEvent::ignore(), setFocusPolicy(),
focusInEvent(), focusOutEvent(), event(), QKeyEvent
*/
qt'QWidget::keyReleaseEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4000)
void QWidget::keyReleaseEvent( QKeyEvent *e )
{
e->ignore();
}
/*!
This event handler can be reimplemented in a subclass to receive
keyboard focus events (focus received) for the widget.
A widget normally must setFocusPolicy() to something other than
NoFocus in order to receive focus events. (Note that the
application programmer can call setFocus() on any widget, even those
that do not normally accept focus.)
The default implementation updates the widget if it accepts
focus (see focusPolicy()). It also calls setMicroFocusHint(), hinting any
system-specific input tools about the focus of the user's attention.
\sa focusOutEvent(), setFocusPolicy(),
keyPressEvent(), keyReleaseEvent(), event(), QFocusEvent
*/
qt'QWidget::focusInEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4022)
void QWidget::focusInEvent( QFocusEvent * )
{
if ( focusPolicy() != NoFocus || !isTopLevel() ) {
update();
if ( testWState(WState_AutoMask) )
updateMask();
setMicroFocusHint(width()/2, 0, 1, height(), FALSE);
}
}
/*!
This event handler can be reimplemented in a subclass to receive
keyboard focus events (focus lost) for the widget.
A widget normally must setFocusPolicy() to something other than
NoFocus in order to receive focus events. (Note that the
application programmer can call setFocus() on any widget, even those
that do not normally accept focus.)
The default implementation calls repaint() since the widget's
colorGroup() changes from active to normal, so the widget probably
needs repainting. It also calls setMicroFocusHint(), hinting any
system-specific input tools about the focus of the user's attention.
\sa focusInEvent(), setFocusPolicy(),
keyPressEvent(), keyReleaseEvent(), event(), QFocusEvent
*/
qt'QWidget::focusOutEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4050)
void QWidget::focusOutEvent( QFocusEvent * )
{
if ( focusPolicy() != NoFocus || !isTopLevel() ){
update();
if ( testWState(WState_AutoMask) )
updateMask();
}
}
/*!
Returns the currently set micro focus hint for this widget.
\sa setMicroFocusHint()
*/
qt'QWidget::microFocusHint() (./qt-2.1.0/src/kernel/qwidget.cpp:4065)
QRect QWidget::microFocusHint() const
{
if ( !extra || extra->micro_focus_hint.isEmpty() )
return QRect(width()/2, 0, 1, height() );
else
return extra->micro_focus_hint;
}
/*!
This event handler can be reimplemented in a subclass to receive
widget enter events.
An event is sent to the widget when the mouse cursor enters the widget.
\sa leaveEvent(), mouseMoveEvent(), event()
*/
qt'QWidget::enterEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4084)
void QWidget::enterEvent( QEvent * )
{
}
/*!
This event handler can be reimplemented in a subclass to receive
widget leave events.
A leave event is sent to the widget when the mouse cursor leaves
the widget.
\sa enterEvent(), mouseMoveEvent(), event()
*/
qt'QWidget::leaveEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4098)
void QWidget::leaveEvent( QEvent * )
{
}
/*!
This event handler can be reimplemented in a subclass to receive
widget paint events.
When the paint event occurs, the update region QPaintEvent::region()
normally has been cleared to the background color or pixmap. An
exception is when repaint(FALSE) is called or the widget sets the
WRepaintNoErase or WResizeNoErase flag. Inside the paint event
handler, QPaintEvent::erased() carries this information.
For many widgets it is sufficient to redraw the entire widget each time,
but some need to consider the update
\link QPaintEvent::rect() rectangle\endlink
or
\link QPaintEvent::region() region\endlink
of the QPaintEvent to avoid slow update.
During paintEvent(), any QPainter you create on the widget will be
clipped to at most the area covered by the update region.
update() and repaint() can be used to force a paint event.
\sa event(), repaint(), update(), QPainter, QPixmap, QPaintEvent
*/
qt'QWidget::paintEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4127)
void QWidget::paintEvent( QPaintEvent * )
{
}
/*!
This event handler can be reimplemented in a subclass to receive
widget move events. When the widget receives this event, it is
already at the new position.
The old position is accessible through QMoveEvent::oldPos().
\sa resizeEvent(), event(), move(), QMoveEvent
*/
qt'QWidget::moveEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4142)
void QWidget::moveEvent( QMoveEvent * )
{
}
/*!
This event handler can be reimplemented in a subclass to receive
widget resize events. When resizeEvent() is called, the widget
already has its new geometry. The old size is accessible through
QResizeEvent::oldSize(), though.
The widget will be erased and receive a paint event immediately
after processing the resize event. No drawing has to (and should) be
done inside this handler.
Widgets that have been created with the \c WResizeNoErase flag will not
be erased. Nevertheless, they will receive a paint event for their
entire area afterwards. Again, no drawing needs to be done inside
this handler.
The default implementation calls updateMask() if the widget
has \link QWidget::setAutoMask() automatic masking\endlink
enabled.
\sa moveEvent(), event(), resize(), QResizeEvent, paintEvent()
*/
qt'QWidget::resizeEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4169)
void QWidget::resizeEvent( QResizeEvent * )
{
if ( testWState(WState_AutoMask) )
updateMask();
}
/*!
This event handler can be reimplemented in a subclass to receive
widget close events.
The default implementation calls e->accept(), which hides this widget.
See the QCloseEvent documentation for more details.
\sa event(), hide(), close(), QCloseEvent
*/
qt'QWidget::closeEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4185)
void QWidget::closeEvent( QCloseEvent *e )
{
e->accept();
}
/*!
This event handler is called when a drag is in progress and the
mouse enters this widget.
See the \link dnd.html Drag-and-drop documentation\endlink for
an overview of how to provide drag-and-drop in your application.
\sa QTextDrag, QImageDrag, QDragEnterEvent
*/
qt'QWidget::dragEnterEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4200)
void QWidget::dragEnterEvent( QDragEnterEvent * )
{
}
/*!
This event handler is called when a drag is in progress and the
mouse enters this widget, and whenever it moves within
the widget.
See the \link dnd.html Drag-and-drop documentation\endlink for
an overview of how to provide drag-and-drop in your application.
\sa QTextDrag, QImageDrag, QDragMoveEvent
*/
qt'QWidget::dragMoveEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4214)
void QWidget::dragMoveEvent( QDragMoveEvent * )
{
}
/*!
This event handler is called when a drag is in progress and the
mouse leaves this widget.
See the \link dnd.html Drag-and-drop documentation\endlink for
an overview of how to provide drag-and-drop in your application.
\sa QTextDrag, QImageDrag, QDragLeaveEvent
*/
qt'QWidget::dragLeaveEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4227)
void QWidget::dragLeaveEvent( QDragLeaveEvent * )
{
}
/*!
This event handler is called when the drag is dropped on this
widget.
See the \link dnd.html Drag-and-drop documentation\endlink for
an overview of how to provide drag-and-drop in your application.
\sa QTextDrag, QImageDrag, QDropEvent
*/
qt'QWidget::dropEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4240)
void QWidget::dropEvent( QDropEvent * )
{
}
/*!
This event handler can be reimplemented in a subclass to receive
widget show events.
Non-spontaneous show events are sent to widgets right before they are
shown. Spontaneous show events of toplevel widgets are delivered
afterwards, naturally.
\sa event(), QShowEvent
*/
qt'QWidget::showEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4255)
void QWidget::showEvent( QShowEvent * )
{
if ( focusWidget() )
return;
else if ( focusPolicy() )
setFocus();
else
focusNextPrevChild( TRUE );
}
/*!
This event handler can be reimplemented in a subclass to receive
widget hide events.
Hide events are sent to widgets right after they have been hidden.
\sa event(), QHideEvent
*/
qt'QWidget::hideEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4273)
void QWidget::hideEvent( QHideEvent * )
{
}
/*!
This event handler can be reimplemented in a subclass to receive
custom events. Custom events are user-defined events with a type
value at least as large as the "User" item of the QEvent::Type enum,
and is typically a QCustomEvent or QCustomEvent subclass.
\sa event(), QCustomEvent
*/
qt'QWidget::customEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4285)
void QWidget::customEvent( QCustomEvent * )
{
}
#if defined(_WS_MAC_)
/*!
This special event handler can be reimplemented in a subclass to receive
native Macintosh events.
If the event handler returns FALSE, this native event is passed back to
Qt, which translates the event into a Qt event and sends it to the
widget. If the event handler returns TRUE, the event is stopped.
\warning This function is not portable.
QApplication::macEventFilter()
*/
qt'QWidget::macEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4305)
bool QWidget::macEvent( MSG * )
{
return FALSE;
}
#elif defined(_WS_WIN_)
/*!
This special event handler can be reimplemented in a subclass to receive
native Windows events.
If the event handler returns FALSE, this native event is passed back to
Qt, which translates the event into a Qt event and sends it to the
widget. If the event handler returns TRUE, the event is stopped.
\warning This function is not portable.
QApplication::winEventFilter()
*/
qt'QWidget::winEvent() (./qt-2.1.0/src/kernel/qwidget.cpp:4325)
bool QWidget::winEvent( MSG * )
{
return FALSE;
}
#elif defined(_WS_X11_)
/*!
This special event handler can be reimplemented in a subclass to receive
native X11 events.
If the event handler returns FALSE, this native event is passed back to
Qt, which translates the event into a Qt event and sends it to the
widget. If the event handler returns TRUE, the event is stopped.
\warning This function is not portable.
QApplication::x11EventFilter()
*/
qt'QWidget::x11Event() (./qt-2.1.0/src/kernel/qwidget.cpp:4345)
bool QWidget::x11Event( XEvent * )
{
return FALSE;
}
#endif
/*!\obsolete
The return value is meaningless
\sa setFontPropagation()
*/
QWidget::PropagationMode QWidget::fontPropagation() const
{
return SameFont;
}
/*!\obsolete
Calling this function has no effect.
*/
qt'QWidget::setFontPropagation() (./qt-2.1.0/src/kernel/qwidget.cpp:4370)
void QWidget::setFontPropagation( PropagationMode )
{
}
/*! \obsolete
The return value is meaningless
*/
QWidget::PropagationMode QWidget::palettePropagation() const
{
return SamePalette;
}
/*! \obsolete
Calling this function has no effect.
*/
qt'QWidget::setPalettePropagation() (./qt-2.1.0/src/kernel/qwidget.cpp:4390)
void QWidget::setPalettePropagation( PropagationMode )
{
}
/*!
Transparent widgets use a \link setMask() mask \endlink to define
their visible region. QWidget has some built-in support to make the
task of recalculating the mask easier. When setting auto mask to
TRUE, updateMask() will be called whenever the widget is resized or
changes its focus state.
Note: When you re-implement resizeEvent(), focusInEvent() or
focusOutEvent() in your custom widgets and still want to ensure that
the auto mask calculation works, you will have to add
\code
if ( autoMask() )
updateMask();
\endcode
at the end of your event handlers. Same holds for all member
functions that change the appearance of the widget in a way that a
recalculation of the mask is necessary.
While being a technically appealing concept, masks have one big
drawback: when using complex masks that cannot be expressed easily
with relatively simple regions, they tend to be very slow on some
window systems. The classic example is a transparent label. The
complex shape of its contents makes it necessary to represent its
mask by a bitmap, which consumes both memory and time. If all you
want is to blend the background of several neighboring widgets
together seamlessly, you may probably want to use
setBackgroundOrigin() rather than a mask.
\sa autoMask(), updateMask(), setMask(), clearMask(), setBackgroundOrigin()
*/
qt'QWidget::setAutoMask() (./qt-2.1.0/src/kernel/qwidget.cpp:4427)
void QWidget::setAutoMask( bool enable )
{
if ( enable == autoMask() )
return;
if ( enable ) {
setWState(WState_AutoMask);
updateMask();
} else {
clearWState(WState_AutoMask);
clearMask();
}
}
/*!
Returns whether or not the widget has the auto mask feature enabled.
\sa setAutoMask(), updateMask(), setMask(), clearMask()
*/
qt'QWidget::autoMask() (./qt-2.1.0/src/kernel/qwidget.cpp:4447)
bool QWidget::autoMask() const
{
return testWState(WState_AutoMask);
}
/*! \enum QWidget::BackgroundOrigin
This enum defines the origin used to draw a widget's background
pixmap.
<ul>
<li> \c WidgetOrigin - the pixmap is drawn in the widget's coordinate system.
<li>\c ParentOrigin - the pixmap is drawn in the parent's coordinate system.
</ul>
*/
/*!
Sets the widget's background to be drawn relative to \a origin,
which is either of \c WidgetOrigin (the default) or \c ParentOrigin.
This makes a difference only if the widget has a background pixmap
where the positioning matters. In such case, using \c ParentOrigin
for several neighboring widgets makes the background blend together
seamlessly.
\sa backgroundOrigin(), backgroundPixmap(), setBackgroundMode()
*/
qt'QWidget::setBackgroundOrigi