当前位置: 首页 > news >正文

QT6 源(37):界面组件的总基类 QWidget 的源码阅读(下,c++ 代码部分)

(1) QT 在 c++ 的基础上增加了自己的编译器,以支持元对象系统和 UI 界面设计,有 MOC 、 UIC 等 QT 自己的编译器。本节的源代码里,为了减少篇幅,易于阅读,去除了上篇中的属性部分, 上篇,QWidget 的属性部分

(2)源代码都来自于头文件 qwidget . h ,注释来自于官方文档,或机翻或原文。两篇加起来是 2000 行:

#ifndef QWIDGET_H
#define QWIDGET_HQT_BEGIN_NAMESPACE  //说明本类 QWidget定义于最大的 QT_BEGIN_NAMESPACE空间class QWidgetData {...}  //本类 QWidget的数据成员//前已阅读了 QPaintDevice,此类没啥内容,只有一些读属性的函数,反馈绘图方面的配置属性
class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
{Q_OBJECT  //宏定义,再次插入此宏private:Q_DISABLE_COPY(QWidget) //禁止对本类的复制Q_PRIVATE_SLOT(d_func(), void _q_showIfNotHidden())Q_PRIVATE_SLOT(d_func(), QWindow *_q_closestWindowHandle())QWidgetData * data; //本类的数据成员public:
public://This enum describes how to render the widget when calling QWidget::render().enum RenderFlag //这是定义了一个渲染标志{   DrawWindowBackground = 0x1,                   //默认情况下,此选项已启用。//如果您启用此选项,即使未设置 autoFillBackground,小部件的背景也会渲染到目标中。DrawChildren         = 0x2,//如果您启用此选项,则小部件的子项将递归地渲染到目标中。默认情况下,此选项已启用。IgnoreMask           = 0x4 //If you enable this option,//the widget's QWidget::mask() is ignored when rendering into the target.//By default, this option is disabled.};Q_DECLARE_FLAGS(RenderFlags, RenderFlag)//定义了枚举量  RenderFlags = QFlags<RenderFlag>//Constructs a widget which is a child of parent, with widget flags set to f.//The widget flags argument, f, is normally 0,//but it can be set to customize the frame of a window//(i.e. parent must be nullptr). To customize the frame,//use a value composed from the bitwise OR of any of the window flags.explicit QWidget( QWidget * parent = nullptr, //构造函数Qt::WindowFlags f = Qt::WindowFlags());// WindowFlags = QFlags<WindowType> 这个枚举类 WindowType 有20 多项~QWidget();int devType() const override; //无注释//typedef QIntegerForSizeof<void *>::Unsigned quintptr;//# define QT_PREPEND_NAMESPACE(name) ::name//typedef QT_PREPEND_NAMESPACE(quintptr) WId;//所以 WId = ::quintptr = 8 字节无符号数WId winId() const; //返回小部件的窗口系统标识符。//原则上是便携的,但如果你使用它,你可能会做一些不可移植的事情。小心。//如果小部件是非本地(外星)的,并且对其调用了winld(),则该小部件将获得一个本地句柄。//这个值可能在运行时改变。//类型为 QEvent:WinldChange 的事件将在窗口系统标识符改变后发送给该小部件。void createWinId(); // internal, going away 无注释,似乎是 QT 的内部函数//private: QWidgetData * data; //本类的数据成员inline WId internalWinId() const //class QWidgetData:: WId winid;{ return data->winid; }//Returns the effective window system identifier of the widget,//i.e. the native parent's window system identifier.//If the widget is native, this function returns the native widget ID.//Otherwise, the window ID of the first native parent widget, i.e.,//the top-level widget that contains this widget, is returned.//Note: We recommend that you do not store this value as//it is likely to change at run-time.WId effectiveWinId() const;//class Q_WIDGETS_EXPORT QStyle : public QObject 这是有 800多行的大类,略QStyle * style()   const;  // GUI style settingvoid  setStyle(QStyle *);  // Widget types and states//警告:此函数 setStyle 特别适用于演示目的,您希望展示Ot的样式功能。//实际应用程序应避免使用此函数而应使用一致的GUI样式。//警告:目前不支持自定义 OStyle 子类使用 Ot 样式表。我们计划在未来的某个版本中解决这个问题。#if QT_DEPRECATED_SINCE(6, 1)  //被报废的函数QT_DEPRECATED_VERSION_X_6_1("Use isWindow()")bool isTopLevel() const;
#endif//如果小部件是一个独立的窗口,则返回true,否则返回false。//窗口是一个小部件,它不是任何其他小部件的视觉子项,通常具有边框和窗口标题。//-个窗口可以有一个父容器。然后它会与其父容器分组,//当父容器被删除时会被删除,当父容器被最小化时会被最小化等。//如果窗口管理器支持,它还会与其父容器有一个共同的任务栏条目。//QDialog和QMainWindow小部件默认是窗口,即使构造函数中指定了父小部件。//这种行为由Qt:Window标志指定。bool isWindow() const { return (windowType() & Qt::Window); }//This property Modal holds whether the widget is a modal widget。//This property only makes sense for windows.//A modal widget prevents widgets in all other windows from getting any input.//By default, this property is false.bool isModal() const { return data->window_modality != Qt::NonModal; }//Q_PROPERTY(bool modal READ isModal)属性的读函数Qt::WindowModality windowModality() const; //属性的读写函数void setWindowModality(Qt::WindowModality windowModality);//Q_PROPERTY(Qt::WindowModality windowModality//READ windowModality WRITE setWindowModality)bool isEnabledTo(const QWidget *ancestor) const;bool isEnabled() const { return !testAttribute(Qt::WA_Disabled); }//Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)public Q_SLOTS:void setEnabled(bool); //属性的写函数//Disables widget input events if disable is true;//otherwise enables input events.void setDisabled(bool disable);//Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified)void setWindowModified(bool); //形参可变public:  // Widget coordinates  本段全是属性的读写函数bool  isWindowModified() const;//Q_PROPERTY(QRect frameGeometry READ frameGeometry)QRect   frameGeometry() const; //属性的读函数//Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry) //属性的读函数const QRect &      geometry() const { return data->crect; }void     setGeometry(const QRect &);inline void     setGeometry(int x, int y, int w, int h){     setGeometry(QRect(ax, ay, aw, ah)); }//Q_PROPERTY(QRect normalGeometry READ normalGeometry)QRect  normalGeometry() const;//属性的读函数int x() const; //Q_PROPERTY(int x READ x)int y() const; //Q_PROPERTY(int y READ y)inline   int width  () const { return data->crect.width (); }//Q_PROPERTY(int width  READ width )//Q_PROPERTY(int height READ height)inline   int height () const { return data->crect.height(); }inline   QRect rect () const  //Q_PROPERTY(QRect rect READ rect){ return QRect(0, 0, data->crect.width(), data->crect.height()); }//class QRect { int x1; int y1; int x2; int y2; } 矩形把握对角两个点//class QSize { int wd; int ht;} 宽与高QRect   childrenRect  () const;//Q_PROPERTY(QRect   childrenRect   READ childrenRect)//Q_PROPERTY(QPoint pos READ pos WRITE move DESIGNABLE false STORED false)QPoint                       pos () const;void move(const QPoint &);void move(int x, int y  ){    move(QPoint(ax, ay)); }QRegion childrenRegion() const;//Q_PROPERTY(QRegion childrenRegion READ childrenRegion)//Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize)QSize   minimumSize() const;void setMinimumSize(int minw, int minh);void setMinimumSize(const QSize &){    setMinimumSize(s.width(),s.height()); }//Q_PROPERTY(int minimumWidth  READ minimumWidth  WRITE setMinimumWidth ...)int     minimumWidth ()   const { return minimumSize().width (); }void setMinimumWidth(int minw); //QSize minimumSize() const; 本类成员函数//Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight ...)int     minimumHeight()   const { return minimumSize().height(); }void setMinimumHeight(int minh);//Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize)QSize   maximumSize() const;void setMaximumSize(int maxw, int maxh);void setMaximumSize(const QSize &){    setMaximumSize(s.width(),s.height()); }//Q_PROPERTY(int maximumWidth  READ maximumWidth  WRITE setMaximumWidth ...)int     maximumWidth ()   const { return maximumSize().width(); }void setMaximumWidth(int maxw); //QSize maximumSize() const; 本类成员函数//Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight ...)int     maximumHeight() const;void setMaximumHeight(int maxh);//Q_PROPERTY(QSize size READ size WRITE resize ...)QSize  size () const { return data->crect.size(); }void resize (const QSize &); //写函数构成重载void resize (int w,  int h){    resize (QSize(w, h)); }QSize frameSize  () const; //Q_PROPERTY(QSize frameSize READ frameSize)#ifdef Q_QDOCvoid setupUi(QWidget *widget);
#endif//Q_PROPERTY(QSize sizeIncrement READ sizeIncrement WRITE setSizeIncrement)QSize    sizeIncrement() const;void  setSizeIncrement(int w, int h );void  setSizeIncrement(const QSize &){     setSizeIncrement(s.width(),s.height());   }//Q_PROPERTY(QSize baseSize READ baseSize WRITE setBaseSize)QSize   baseSize() const;void setBaseSize(int basew, int baseh);void setBaseSize(const QSize &){    setBaseSize(s.width(),s.height()); }//将小部件的最小和最大大小都设置为s,从而防止它增长或缩小。//这将覆盖 QLayout 设定的默认大小限制。要解除限制,请将大小设置为OWIDGETSIZE MAX。//或者,如果您希望小部件基于其内容具有固定大小,//则可以调用 OLayout::setSizeConstraint(OLayout::SetFixedSize);void setFixedSize(const QSize & s);void setFixedSize(int w, int h );//Sets the width of the widget to w and the height to h.//将小部件的最小和最大宽度设置为w,而不改变高度。为方便起见提供。void setFixedWidth (int w);void setFixedHeight(int h);// Widget coordinate mapping//将小部件坐标pos转换为全局屏幕坐标。//例如,mapToGlobal(QPointF(0,0)) 将给出该小部件左上角的像素的全球坐标。QPointF mapToGlobal(const QPointF & pos) const;QPoint  mapToGlobal(const QPoint  &    ) const;//class QPointF { qreal xp; qreal yp; } //浮点坐标//class QPoint  { int   xp; int   yp; } //整数坐标//Translates the widget coordinate pos to a coordinate in the parent widget.QPointF mapToParent(const QPointF & pos) const;QPoint  mapToParent(const QPoint  &    ) const;//Translates the widget coordinate pos to the coordinate system of parent.//The parent must not be nullptr and must be a parent of the calling widget.QPointF mapTo(const QWidget * parent, const QPointF & pos) const;QPoint  mapTo(const QWidget *, const QPoint  &) const;//Translates the global screen coordinate pos to widget coordinates.QPointF mapFromGlobal(const QPointF & pos) const;QPoint  mapFromGlobal(const QPoint  &    ) const;//Translates the parent widget coordinate pos to widget coordinates.//Same as mapFromGlobal() if the widget has no parent.QPointF mapFromParent(const QPointF & pos) const;QPoint  mapFromParent(const QPoint  &    ) const;//Translates the widget coordinate pos from the coordinate system of//parent to this widget's coordinate system.//The parent must not be nullptr and must be a parent of the calling widget.QPointF mapFrom(const QWidget * parent, const QPointF & pos) const;QPoint  mapFrom(const QWidget *       , const QPoint  &    ) const;//Returns the window for this widget, i.e. the next ancestor widget that//has (or could have) a window-system frame.//If the widget is a window, the widget itself is returned.//Typical usage is changing the window title:// aWidget->window()->setWindowTitle("New Window Title");QWidget * window() const;inline QWidget * topLevelWidget() const //This function is deprecated.{ return window(); }                    //Use window() instead.//返回此小部件的本地父小部件,即具有系统标识符的下一个祖先小部件,//如果没有任何本地父小部件则为 nullptr。QWidget * nativeParentWidget() const;// Widget appearance functions  //又开始处理属性的读写函数了const QPalette & palette() const;void          setPalette(const QPalette &);// Q_PROPERTY(QPalette palette READ palette WRITE setPalette)//返回小部件的背景角色。 这个不是属性函数//背景角色定义从小部件调色板中使用的刷子,用于渲染背景。//如果没有设置显式的背景角色,则小部件会继承其父级小部件的背景角色。QPalette::ColorRole backgroundRole() const;void             setBackgroundRole(QPalette::ColorRole role);//将小部件的背景角色设置为 role。//背景角色定义从小部件调色板中使用的刷子,用于渲染背景。//如果角色是OPalette::NoRole,则该小部件继承其父类的背景角色。//请注意,样式可以自由选择调色板中的任何颜色。//如果您使用setBackgroundRole()无法获得所需结果,则可以修改调色板或设置样式表。//返回前景角色。//前景角色定义了用于绘制前景的来自小部件调色板的颜色。//如果没有设置显式的前景角色,该函数将返回与背景角色形成对比的角色。QPalette::ColorRole foregroundRole() const;void             setForegroundRole(QPalette::ColorRole role);//将小部件的前景色角色设置为 role。//前景角色定义了用于绘制前景的来自小部件调色板的颜色。//如果角色是OPalette::NoRole,则小部件使用与背景角色形成对比的前景角色。//请注意,样式可以自由选择调色板中的任何颜色。//如果您使用setForegroundRole()无法获得所需的结果,则可以修改调色板或设置样式表。//Q_PROPERTY(QFont font READ font WRITE setFont)const QFont & font() const { return data->fnt; }void       setFont(const QFont &);//Returns the font metrics字体度量 for the widget's current font.//Equivalent to QFontMetrics(widget->font()).QFontMetrics  fontMetrics() const { return QFontMetrics(data->fnt); }//Returns the font info for the widget's current font.//Equivalent to QFontInfo(widget->font()).QFontInfo     fontInfo()    const { return QFontInfo(data->fnt); }#ifndef QT_NO_CURSOR //要使用光标的//Q_PROPERTY(QCursor cursor READ cursor WRITE setCursor RESET unsetCursor)QCursor   cursor() const;void   setCursor(const QCursor &);void unsetCursor(); //重置光标
#endif//如果小部件位于鼠标光标下方,则返回true;否则返回false。//This value is not updated properly during drag and drop operations.bool underMouse()       const { return testAttribute(Qt::WA_UnderMouse)   ; }//Q_PROPERTY(bool mouseTracking READ hasMouseTracking WRITE setMouseTracking)bool hasMouseTracking() const { return testAttribute(Qt::WA_MouseTracking); }//属性void setMouseTracking(bool enable) { setAttribute(Qt::WA_MouseTracking, enable); }bool hasTabletTracking() const{ return testAttribute(Qt::WA_TabletTracking); }void setTabletTracking(bool enable){ setAttribute(Qt::WA_TabletTracking, enable);}//Q_PROPERTY(bool tabletTracking  这似乎是平板电脑与触摸笔之间的跟踪//        READ hasTabletTracking WRITE setTabletTracking)//Returns the mask currently set on a widget.//If no mask is set the return value will be an empty region.QRegion mask() const;  //没有此属性//Causes only the pixels of the widget for which bitmap has a//corresponding 1 bit to be visible.//If the region includes pixels outside the rect() of the widget,//window system controls in that area may or may not be visible,//depending on the platform.//Note that this effect can be slow if the region is particularly complex.//Masked widgets receive mouse events only on their visible portions.void setMask(const QBitmap & bitmap);//Causes only the parts of the widget which overlap region to be visible.//If the region includes pixels outside the rect() of the widget,//window system controls in that area may or may not be visible,//depending on the platform.void setMask(const QRegion & region);void clearMask(); //Removes any mask set by setMask().//Renders the sourceRegion of this widget into the target using renderFlags//to determine how to render. Rendering starts at targetOffset in the target.//If sourceRegion is a null region, this function will use QWidget::rect()//as the region, i.e. the entire widget.//Ensure that you call QPainter::end() for//the target device's active painter (if any) before rendering.void render(QPaintDevice * target,const QPoint       & targetOffset = QPoint (),const QRegion      & sourceRegion = QRegion(),RenderFlags renderFlags = RenderFlags(DrawWindowBackground | DrawChildren));//This is an overloaded function.//Renders the widget into the painter's QPainter::device().
//Transformations and settings applied to the painter will be used when rendering.void render(QPainter     * painter,const QPoint       & targetOffset = QPoint(),const QRegion      & sourceRegion = QRegion(),RenderFlags renderFlags = RenderFlags(DrawWindowBackground | DrawChildren));//将小部件渲染为受给定矩形限制的位图。如果小部件有任何子元素,则它们也将在适当的位置绘制。//如果指定了无效大小的矩形(默认为这种情况),则整个小部件将被绘制。//注:此函数可以通过元对象系统和 QML调用。参见QINVOKABLE。Q_INVOKABLE QPixmap //看来此函数也是关于绘图渲染的grab(const QRect &rectangle = QRect( QPoint(0, 0), QSize(-1, -1) ) );#if QT_CONFIG(graphicseffect) //有此定义的。但这不是属性//The graphicsEffect function returns a pointer to the widget's graphics effect.//If the widget has no graphics effect, nullptr is returned.QGraphicsEffect * graphicsEffect() const;void           setGraphicsEffect(QGraphicsEffect *effect);//The setGraphicsEffect function is for setting the widget's graphics effect.//Sets effect as the widget's effect. If there already is an effect//installed on this widget, QWidget will delete the existing effect before//installing the new effect.//If effect is the installed effect on a different widget,//setGraphicsEffect() will remove the effect from the widget and//install it on this widget.//QWidget takes ownership of effect.//Note: This function will apply the effect on itself and all its children.//Note: Graphics effects are not supported for OpenGL-based widgets,//such as QGLWidget, QOpenGLWidget and QQuickWidget.#endif // QT_CONFIG(graphicseffect)#ifndef QT_NO_GESTURES  //经测试,确实没定义这个宏//Subscribes订阅 the widget to a given gesture with specific flags.void   grabGesture(Qt::GestureType  type , //这是关于手势点击平移滑动的枚举量Qt::GestureFlags flags = Qt::GestureFlags());//关于父子容器上手势传递的枚举量 GestureFlagsvoid ungrabGesture(Qt::GestureType type);//Unsubscribes the widget from a given gesture type
#endifQString windowTitle() const;public Q_SLOTS:  //信号的槽函数,但也是属性 windowTitle的写函数void setWindowTitle(const QString &);//Q_PROPERTY(QString windowTitle READ windowTitle//WRITE setWindowTitle NOTIFY windowTitleChanged)#ifndef QT_NO_STYLE_STYLESHEET //信号的槽函数,但也是属性 windowTitle的写函数void setStyleSheet(const QString& styleSheet);//Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
#endif  //至此,信号的槽函数定义结束public:
#ifndef QT_NO_STYLE_STYLESHEETQString styleSheet() const; //配合上面的属性 styleSheet 的读函数
#endif//Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon ...)QIcon   windowIcon() const;    //又是关于属性的void setWindowIcon(const QIcon &icon);//Q_PROPERTY(QString windowIconText ...) // deprecatedQString windowIconText() const;void setWindowIconText(const QString &);QString windowRole() const; //Returns the window's role, or an empty string.void setWindowRole(const QString &);//本属性似乎只对 win11 有用//Sets the window's role to role. This only makes sense for windows on X11.//Q_PROPERTY(QString windowFilePath READ windowFilePath WRITE setWindowFilePath)QString windowFilePath() const;void setWindowFilePath(const QString &filePath);//Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity)qreal   windowOpacity() const;void setWindowOpacity(qreal level);#if QT_CONFIG(tooltip) //是有此宏的//Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)QString toolTip() const;void setToolTip(const QString &);//Q_PROPERTY(int toolTipDuration READ toolTipDuration WRITE setToolTipDuration)int     toolTipDuration() const;void setToolTipDuration(int msec);
#endif#if QT_CONFIG(statustip)//Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip)QString statusTip() const;void setStatusTip(const QString &); 
#endif#if QT_CONFIG(whatsthis)//Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis)QString whatsThis() const;void setWhatsThis(const QString &);
#endif#ifndef QT_NO_ACCESSIBILITY//Q_PROPERTY(QString accessibleName READ accessibleName WRITE setAccessibleName)QString accessibleName() const;void setAccessibleName(const QString &name);//Q_PROPERTY(QString accessibleDescription//              READ accessibleDescription WRITE setAccessibleDescription)QString accessibleDescription() const;void setAccessibleDescription(const QString &description);
#endif//Q_PROPERTY(Qt::LayoutDirection layoutDirection//     READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection)Qt::LayoutDirection layoutDirection() const;void   setLayoutDirection(Qt::LayoutDirection direction);void unsetLayoutDirection();//Q_PROPERTY(QLocale locale READ locale WRITE setLocale RESET unsetLocale)QLocale locale() const;void   setLocale(const QLocale &locale);void unsetLocale();inline bool isRightToLeft() const{ return layoutDirection() == Qt::RightToLeft; }inline bool isLeftToRight() const{ return layoutDirection() == Qt::LeftToRight; }public Q_SLOTS:inline void setFocus() { setFocus(Qt::OtherFocusReason); }public: //Q_PROPERTY(bool focus READ hasFocus) 说明这不是属性 focus的写函数void setFocus(Qt::FocusReason reason); //函数重载,无参版本作为槽函数bool hasFocus() const;void clearFocus();  //Takes keyboard input focus from the widget.//If the widget has active focus, a focus out event is sent to//this widget to tell it that it has lost the focus.//This widget must enable focus setting in order to get the keyboard input focus,//i.e. it must call setFocusPolicy().//Q_PROPERTY(bool isActiveWindow READ isActiveWindow)bool isActiveWindow() const;void activateWindow(); //将包含此小部件的顶级小部件设置为活动窗口。//活动窗口是具有键盘输入焦点的可见顶层窗口。//这个函数执行的操作与在顶层窗口的标题栏上单击鼠标相同。在X11上,结果取决于窗口管理器。//如果你想确保窗口也堆叠在顶部,你还应该调用raise()。注意,窗口必须是可见的,//否则activateWindow()没有效果。//在Windows上,如果在应用程序当前不是活动窗口时调用此函数,则不会使其成为活动窗口。//它将更改任务栏条目的颜色,以表示窗口在某种程度上发生了变化。//这是因为微软不允许应用程序中断用户当前在另一个应用程序中正在做的事情。//Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy)Qt::FocusPolicy focusPolicy() const;void         setFocusPolicy(Qt::FocusPolicy policy);//Puts the second widget after the first widget in the focus order.//It effectively removes the second widget from its focus chain and//inserts it after the first widget.//If first or second has a focus proxy,//setTabOrder() correctly substitutes the proxy.//注意:自Qt5.10以来:具有子控件作为焦点代理的控件被视为复合控件。//在一或两个复合控件之间设置标签顺序时,每个内部的局部标签顺序将被保留。//这意味着如果两个控件都是复合控件,the resulting tab order will be from//the last child inside first, to the first child inside second.static void setTabOrder(QWidget * first, QWidget * second); //静态成员函数//Returns the focus proxy, or nullptr if there is no focus proxy.QWidget * focusProxy() const;  //这不是属性void   setFocusProxy(QWidget * w);//将小部件的焦点代理设置为小部件w。如果 w为nullptr,则该函数将重置此小部件,使其没有焦点代理。//-些小部件可以“获得焦点”,但创建子小部件,例如QLineEdit,以实际处理焦点。//在这种情况下,小部件可以将行编辑 line edit 设置为它的焦点代理。//setFocusProxy()设置当“此控件”获得焦点时实际获得焦点的控件。
//If there is a focus proxy, setFocus() and hasFocus() operate on the focus proxy.//If "this widget" is the focus widget,//then setFocusProxy() moves focus to the new focus proxy。//Q_PROPERTY(Qt::ContextMenuPolicy contextMenuPolicy//      READ contextMenuPolicy WRITE setContextMenuPolicy)Qt::ContextMenuPolicy contextMenuPolicy() const;void setContextMenuPolicy(Qt::ContextMenuPolicy policy);//抓取鼠标输入。这个小部件会接收所有鼠标事件,直到调用releaseMouse()为止;//其他小部件根本不会接收到任何鼠标事件。键盘事件不受影响。//如果您想捕获键盘事件,请使用grabKeyboard()。
//Warning: Bugs in mouse-grabbing applications very often lock the terminal.
//Use this function with extreme caution,
//and consider using the -nograb command line option while debugging.
//在使用Qt时,几乎不需要抓取鼠标,因为Qt会明智地抓取和释放鼠标。
//特别是,当按下鼠标按钮时,Qt会抓取鼠标,并在最后一次释放按钮之前保持抓取状态。//注意:只有可见的widget才能抓取鼠标输入。//如果widget的isVisible()返回false,则该widget不能调用grabMouse()。void grabMouse();  // Grab functions
#ifndef QT_NO_CURSORvoid grabMouse(const QCursor & cursor);
//Grabs the mouse input and changes the cursor shape.
//The cursor will assume shape cursor (for as long as the mouse focus is grabbed) and
//this widget will be the only one to receive mouse events until
//releaseMouse() is called().
//Warning: Grabbing the mouse might lock the terminal.
#endifvoid releaseMouse(); //Releases the mouse grab.//抓取键盘输入。这个小部件接收所有键盘事件,直到调用releaseKeyboard ();//其他小部件根本不会接收到键盘事件。鼠标事件不受影响。如果您想捕获鼠标事件,请使用grabMouse()。//焦点小部件不受影响,只是它不会接收任何键盘事件。//setFocus()照常移动焦点,但新的焦点小部件只有在调用 releaseKeyboard()之后才会接收键盘事件。//如果当前有另一个小部件正在抓取键盘输入,则首先释放该小部件的抓取。//Grabs the keyboard input.//This widget receives all keyboard events until releaseKeyboard() is called;//other widgets get no keyboard events at all.//Mouse events are not affected. Use grabMouse() if you want to grab that.//The focus widget is not affected,//except that it doesn't receive any keyboard events.//setFocus() moves the focus as usual,but the new focus widget receives//keyboard events only after releaseKeyboard() is called.//If a different widget is currently grabbing keyboard input,//that widget's grab is released first.void    grabKeyboard();void releaseKeyboard();  //Releases the keyboard grab.#ifndef QT_NO_SHORTCUT  //快捷方式 Shortcut//为 Qt的快捷键系统添加一个快捷方式,该快捷方式在指定上下文 context中监视给定的键序列  key。//如果上下文是Qt:ApplicationShortcut,则快捷键适用于整个应用程序。//否则,它要么是此小部件的本地快捷键,Qt::WidgetShortcut,//要么是窗口本身的快捷键,Ot::WindowShortcut。//如果相同的键序列已被多个小部件捕获,当键序列发生时,//会向所有适用的小部件发送,QEvent::Shortcut事件,其顺序不确定,//但“ambiguous”标志设置为 true。//警告:你通常不需要使用这个函数;//相反,用你需要的快捷键序列创建QActions(如果你也想要相同的菜单选项和工具栏按钮),//或者如果你只需要键序列创建OShortcuts。OAction和OShortcut都为您处理所有事件过滤,//并提供在用户触发键序列时触发的信号,因此比这个低级功能更易于使用。int     grabShortcut(const QKeySequence & key,Qt::ShortcutContext context = Qt::WindowShortcut);void releaseShortcut(int id);//从Qt的快捷键系统中移除具有给定ID的快捷方式。//该小部件将不再接收QEvent::Shortcut事件,用于快捷键的键序列//(除非它还有其他具有相同键序列的快捷键)。//警告:您通常不需要使用此函数,因为Qt的快捷方式系统在父控件被销毁时会自动删除快捷方式。//最好使用QAction或QShortcut来处理快捷方式,因为它们比此低级函数更易于使用。//还要注意,这是一个昂贵的操作。//如果 enable 为 true,则具有给定 id 的快捷键被启用;否则,快捷键被禁用。//警告:通常你不应该需要使用这个函数,//因为Qt的快捷键系统会自动启用/禁用快捷键,当小部件变为隐藏/可见并获得或失去焦点时。//最好使用QAction或QShortcut来处理快捷键,因为它们比这个低级函数更易于使用。void     setShortcutEnabled   (int id, bool enable = true);void     setShortcutAutoRepeat(int id, bool enable = true);//如果 enable 为 true,则启用具有给定 id 的快捷键的自动重复;否则禁用。
#endif//返回当前正在抓取鼠标输入的控件。//如果此应用程序中当前没有小部件捕获鼠标,则返回 nullptr。static QWidget *    mouseGrabber();static QWidget * keyboardGrabber();//返回当前正在抓取键盘输入的控件。//如果此应用程序中当前没有小部件抓取键盘,则返回`nullptr~。// Update/refresh functions//Q_PROPERTY(bool updatesEnabled//           READ updatesEnabled WRITE setUpdatesEnabled DESIGNABLE false)inline bool       updatesEnabled() const //指重新绘制界面,而非操作系统的版本更新{ return !testAttribute(Qt::WA_UpdatesDisabled); }void           setUpdatesEnabled(bool enable);#if QT_CONFIG(graphicsview)   //经测试,本宏是被定义的//返回图形视图中相应嵌入式小部件的代理小部件,否则返回nullptr。QGraphicsProxyWidget *graphicsProxyWidget() const;//Returns the proxy widget for the corresponding embedded widget//in a graphics view; otherwise returns nullptr.
#endifpublic Q_SLOTS:  //又是信号的槽函数//更新小部件,除非已禁用更新或小部件已隐藏。//这个函数不会立即重新绘制;相反,它会在 Qt返回主事件循环时安排一个绘制事件进行处理。//这使得 Qt 能够比调用repaint()更快地优化和减少闪烁。//多次调用 update()通常只会导致-次 paintEvent()调用。//Qt通常在调用paintEvent()之前擦除小部件的区域。//如果设置了Qt::WA_OpaquePaintEvent小部件属性,则小部件负责用不透明颜色绘制其所有像素。   void update ();   //update()函数永远不会导致递归。void repaint();//通过立即调用 paintEvent()直接重新绘制小部件,除非禁用更新或小部件被隐藏。//我们建议只有在需要立即重绘时(例如在动画期间)才使用repaint()方法。//在几乎所有情况下update()方法更好,因为它允许 Qt进行速度优化并最小化闪烁。//警告:如果在可能从paintEvent()调用的函数中调用repaint(),则可能会导致无限递归。public:void update(const QRegion&);void update(const QRect  &);inline void update(int x, int y, int w, int h){    update(QRect(ax, ay, aw, ah)); }void repaint(int x, int y, int w, int h);void repaint(const QRect   &);void repaint(const QRegion &);//Q_PROPERTY(bool visible READ isVisible WRITE setVisible ...)bool isVisible() const            //属性的读写函数{ return testAttribute(Qt::WA_WState_Visible); }
public Q_SLOTS: // Widget management functions //又是信号的槽函数virtual void setVisible(bool visible);void showMinimized (); //Shows the widget minimized, as an icon.//Calling this function only affects windows.void showMaximized (); //Shows the widget maximized.void showFullScreen(); //Shows the widget in full-screen mode.void showNormal    (); //这四个函数都不是属性宏里的函数,与宏无关//Restores the widget after it has been maximized or minimized.void show(); //Shows the widget and its child widgets.//This is equivalent to calling showFullScreen(), showMaximized(),//or setVisible(true), depending on the platform's default behavior//for the window flags.void hide();//Hides the widget. This function is equivalent to setVisible(false).//注:如果您正在使用QDialog或其子类,并且在此函数之后调用show()函数,//则对话框将在其原始位置显示。//关闭此小部件。如果小部件已关闭,则返回 true;否则返回 false。//首先,它向小部件发送QCloseEvent。如果小部件接受关闭事件,则隐藏小部件。//如果它忽略事件,则不会发生任何事情。QWidget::closeEvent()的默认实现接受关闭事件。//如果小部件具有 Qt::WA_DeleteOnClose 标志,则也会删除小部件。//无论小部件是否可见,都会向小部件发送关闭事件。//当具有 Qt:WA OuitOnClose属性的最后一个可见主窗口(即没有父窗口的窗口)被关闭时,//会发出QGuiApplication::lastWindowClosed()信号。//默认情况下,此属性设置给所有除临时窗口(如启动屏幕、工具窗口和弹出菜单)以外的窗口。bool close();void raise(); //将本小部件提升到父小部件堆栈的顶部。//在这次调用之后,该小部件将在任何重叠的兄弟小部件之前可见。//注:在使用activateWindow()时,可以调用此函数以确保窗口堆叠在顶部。void lower();//将小部件降低到父小部件堆栈的底部。//在这次调用之后,该小部件将在任何重叠的兄弟小部件的后面(因此被遮挡)void       setHidden(bool hidden); //Convenience function,
public:                                //equivalent to setVisible(!hidden).inline bool isHidden() const { return testAttribute(Qt::WA_WState_Hidden); }//如果小部件被隐藏,则返回true,否则返回false。//隐藏的部件只有在调用其show()方法时才会显示。当父部件显示时,它不会自动显示。//要检查可见性,请使用!isVisible()代替(注意感叹号)。//isHidden()意味着!isVisible(),// but a widget can be not visible and not hidden at the same time.//这是小部件作为不可见小部件的子小部件的情况。This is the case for widgets that//are children of widgets that are not visible。//如果满足以下条件,则隐藏小部件://它们被创建为独立的窗口;它们被创建为可见小部件的孩子;hide()或setVisible(false)被调用。//将小部件放置在父小部件堆栈中的w下方。为了使这个工作,小部件本身和w必须是兄弟。void stackUnder(QWidget * w);//Saves the current geometry and state for top-level widgets.QByteArray saveGeometry() const;bool    restoreGeometry(const QByteArray &geometry);//Restores the geometry and state of top-level widgets stored in the//byte array geometry. Returns true on success; otherwise returns false.//如果恢复的几何图形超出屏幕范围,将对其进行修改,使其位于可用屏幕几何图形内。void adjustSize();//调整小部件的大小以适合其内容。//如果大小提示有效,即大小提示的宽度和高度>=0,则此函数使用 sizeHint()。//否则,它将大小设置为覆盖所有子控件(所有子控件矩形的并集)的子控件矩形。//对于窗口,屏幕大小也会被考虑在内。如果sizeHint()小于(200,100)且大小策略为扩展,//则窗口至少为(200,100)。窗口的最大大小是屏幕宽度和高度的 2/3。bool isVisibleTo(const QWidget * ancestor) const;//Returns true if this widget would become visible if ancestor is shown;//otherwise returns false.//The true case occurs if neither the widget itself nor//any parent up to but excluding ancestor形参 has been explicitly hidden.//如果该小部件被屏幕上的其他窗口遮挡,此函数仍将返回 true,//但如果它或它们被移动,则可能在物理上可见。isVisibleTo(0)与isVisible()相同。bool isMinimized ()const; //Q_PROPERTY(bool minimized  READ isMinimized )bool isMaximized ()const; //Q_PROPERTY(bool maximized  READ isMaximized )bool isFullScreen()const; //Q_PROPERTY(bool fullScreen READ isFullScreen)//Returns the current window state. The window state is a OR'ed combination of//Qt::WindowState: Qt::WindowMinimized,//Qt::WindowMaximized, Qt::WindowFullScreen, and Qt::WindowActive.Qt::WindowStates windowState() const;  //这不是属性void     overrideWindowState(Qt::WindowStates state); //无官方注释void          setWindowState(Qt::WindowStates state);//Sets the window state to state.//对如果窗口不可见(即isVisible()返回 false)则在调用 show()时窗口状态将生效。//于可见的窗口,更改是即时的。//调用此函数将隐藏小部件。您必须调用show()以使小部件再次可见。//Q_PROPERTY(QSize     sizeHint READ sizeHint)virtual QSize          sizeHint() const;virtual QSize   minimumSizeHint() const;//Q_PROPERTY(QSize minimumSizeHint READ minimumSizeHint)//Q_PROPERTY(QSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy)QSizePolicy    sizePolicy() const;void        setSizePolicy(QSizePolicy);inline void setSizePolicy(QSizePolicy::Policy horizontal,QSizePolicy::Policy vertical ){           setSizePolicy(QSizePolicy(hor, ver)); }//返回给定宽度w时此小部件的首选高度。//如果此小部件具有布局,则默认实现返回布局的首选高度。//如果没有布局,则默认实现返回-1,表示首选高度不依赖于宽度。virtual int     heightForWidth(int w) const; //这不是属性virtual bool hasHeightForWidth(     ) const;//Returns true if the widget's preferred height depends on its width;//otherwise returns false.//返回油漆事件可以发生的未遮挡区域。//对于可见小部件,这是其他小部件未覆盖区域的近似值;否则,这是一个空区域//如果需要,repaint()函数会调用此函数,因此通常不需要调用它。QRegion visibleRegion() const;//The contentsMargins function returns the widget's contents margins.QMargins contentsMargins() const; //非属性void  setContentsMargins(int left, int top, int right, int bottom);void  setContentsMargins(const QMargins &margins);//Sets the margins around the contents of the widget to have the//sizes left, top, right, and bottom.//The margins are used by the layout system,//and may be used by subclasses to specify the area to draw in//(e.g. excluding the frame).//Changing the margins will trigger a resizeEvent().QRect contentsRect() const; //Returns the area inside the widget's margins.public://Returns the layout manager that is installed on this widget,//or nullptr if no layout manager is installed.//The layout manager sets the geometry of the widget's children that//have been added to the layout.QLayout * layout() const;   //这不是属性void   setLayout(QLayout * layout);//将此小部件的布局管理器设置为  layout。//如果此小部件上已经安装了布局管理器,则QWidget将不允许您安装另一个布局管理器。//您必须首先删除现有布局管理器(由layout()返回),然后才能使用新布局调用setLayout()。//如果 layout是另一个小部件的布局管理器,//则setLayout()将重新设置布局,使其成为此小部件的布局管理器。void updateGeometry();//Notifies the layout system that this widget has changed and//may need to change geometry.//Call this function if the sizeHint() or sizePolicy() have changed.//For explicitly hidden widgets, updateGeometry() is a no-op.//The layout system will be notified as soon as the widget is shown.//将小部件的父级设置为 parent,并重置窗口标志。小部件被移动到新父级中的位置(0,0)//如果新父项小部件位于不同的窗口中,//则重新关联的小部件及其子项将按与之前相同的内部顺序附加到新父项小部件的标签链的末尾。//如果移动的小部件之一具有键盘焦点,则setParent()调用clearFocus()以清除该小部件的焦点。//如果新父项小部件与旧父项位于同一窗口中,则设置父项不会更改选项卡顺序或键盘焦点。//如果“新”父项小部件是旧的父项小部件,则此函数不起作用。//注意:作为更改父项的一部分,即使之前可见,小部件也会变得不可见。//必须调用show()以使小部件再次可见。//警告:您几乎不可能需要这个函数。//如果您有一个动态更改其内容的部件,则使用QStackedWidget要容易得多。void   setParent(QWidget *parent);void   setParent(QWidget *parent, Qt::WindowFlags f);//Returns the parent of this widget,//or nullptr if it does not have any parent widget.QWidget * parentWidget() const{ return static_cast<QWidget *>(QObject::parent()); }//将该小部件及其子小部件向右平移dx像素,向下平移dy像素。dx和dy都可以是负数。//滚动后,小部件将接收需要重新绘制的区域的绘制事件。//对于 Qt知道是不透明的的小部件,这仅是新暴露的部分。//例如,如果一个不透明的小部件向左滚动8像素,那么只有右边缘的8像素宽的条纹需要更新。//由于默认情况下小部件会传播其父项的内容,因此您需要设置autoFillBackground 属性,//或使用setAttribute()设置 Ot::WA OpaquePaintEvent属性,以使小部件不透明。//对于使用内容传播的小部件,滚动会导致整个滚动区域的更新。void scroll(int dx, int dy);void scroll(int dx, int dy, const QRect& r);//QRect { int x1; int y1; int x2; int y2; }//This is an overloaded function.//This version only scrolls r and does not move the children of the widget.//If r is empty or invalid, the result is undefined.// Misc. functions//Returns the last child of this widget that setFocus had been called on.//For top level widgets this is the widget that will get focus in case//this window gets activated.//This is not the same as QApplication::focusWidget(),//which returns the focus widget in the currently active window.QWidget * focusWidget          () const;//Returns the next     widget in this widget's focus chain.QWidget *     nextInFocusChain () const;QWidget * previousInFocusChain () const;//returns the previous widget in this widget's focus chain.// drag and drop//Q_PROPERTY(bool acceptDrops READ acceptDrops WRITE setAcceptDrops)bool    acceptDrops() const;void setAcceptDrops(bool on);#ifndef QT_NO_ACTION//actions//Returns the (possibly empty) list of this widget's actions.QList<QAction*> actions() const;//将操作 action 附加到此小部件的操作列表中。//所有QWidgets都有一个QActions列表,但它们可以用许多不同的方式图形化表示。//QAction列表(由actions()返回)的默认用法是创建一个上下文QMenu。//QWidget 应该只包含每个动作的一个实例,//添加一个它已经有的动作不会导致同一个动作在 widget 中出现两次。// action的所有权不会转移到此 QWidget。void addAction (QAction * action);void addActions(const QList<QAction*> &actions);void insertAction (QAction *before, QAction * action);void insertActions(QAction *before, const QList<QAction*> & actions);void removeAction (QAction *action);
#endif//QDOC_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags)inline Qt::WindowFlags windowFlags() const;void                setWindowFlags(Qt::WindowFlags type);//Sets the window flag flag on this widget if on is true;//otherwise clears the flag.void      setWindowFlag (Qt::WindowType, bool on = true);void overrideWindowFlags(Qt::WindowFlags type);//WindowFlags = QFlags<WindowType>//Q_DECLARE_FLAGS(WindowFlags, WindowType)//Sets the window flags for the widget to flags,//without telling the window system.//Warning: Do not call this function unless you really know what you're doing.//Returns the window type of this widget.//This is identical to windowFlags() & Qt::WindowType_Mask.inline Qt::WindowType windowType() const //WindowFlags = QFlags<WindowType>{ return static_cast<Qt::WindowType>(int(data->window_flags & Qt::WindowType_Mask));}//返回具有窗口标识符/句柄ID的widget的指针。//窗口标识符的类型取决于底层窗口系统,实际定义请参见qwindowdefs.h。//如果没有具有此标识符的小部件则返回nullptr。static QWidget * find   (WId);//Returns the visible child widget at the position (x, y)//in the widget's coordinate system.//If there is no visible child widget at the specified position,//the function returns nullptr.QWidget * childAt(const QPoint &p) const;inline QWidget * childAt(int x,    int y) const{   return childAt(QPoint(ax, ay)); }//Sets the attribute attribute on this widget if on is true;//otherwise clears the attribute.void         setAttribute(Qt::WidgetAttribute attribute, bool on = true);inline bool testAttribute(Qt::WidgetAttribute) const{   if (attribute < int(8*sizeof(uint)))return data->widget_attributes & (1<<attribute);return testAttribute_helper(attribute);}//Returns true if attribute attribute is set on this widget;//otherwise returns false.//重新实现:QPaintDevice::paintEngine()返回。   返回小部件的绘制引擎。//请注意,用户不应显式调用此函数,因为它仅用于重新实现目的。该函数由Qt内部调用,//默认实现可能并不总是返回有效的指针。QPaintEngine *paintEngine() const override;//class QWidget : public QObject, public QPaintDevicevoid ensurePolished() const; //确保抛光;    Polish 改进;磨炼;提高;//确保小部件及其子项已被 QStyle 润色(即具有适当的字体和调色板)//QWidget 在完全构建但首次显示之前调用此函数。//如果您希望在执行操作之前确保小部件已润色,则可以调用此函数,//例如,小部件的sizeHint()重实现可能需要正确的字体大小。//请注意,此函数是从sizeHint()的默认实现中调用的。//抛光对于必须在所有构造函数(从基础类以及从子类)调用之后进行的最终初始化非常有用。//如果在小部件打磨时需要更改一些设置,请重新实现 event()并处理 QEvent::Polish 事件类型。//注:该函数被声明为const,以便可以从其他const函数(例如sizeHint())中调用。//Returns true if this widget is a parent,//(or grandparent and so on to any level), of the given child,//and both widgets are within the same window; otherwise returns false.bool isAncestorOf(const QWidget *child) const;#ifdef QT_KEYPAD_NAVIGATION //经测试没有定义这个宏呢bool hasEditFocus() const;void setEditFocus(bool on);
#endif//Q_PROPERTY(bool autoFillBackground//           READ autoFillBackground WRITE setAutoFillBackground)bool    autoFillBackground() const;void setAutoFillBackground(bool enabled);//Returns the QBackingStore this widget will be drawn into.QBackingStore * backingStore() const;//If this is a native widget, return the associated QWindow.//Otherwise return null.//Native widgets include toplevel widgets, QGLWidget, and//child widgets on which winId() was called.QWindow * windowHandle() const;//Returns the screen the widget is on.QScreen * screen() const; //这不是属性void   setScreen(QScreen *);//Sets the screen on which the widget should be shown to screen.//Setting the screen only makes sense for windows.//If necessary, the widget's window will get recreated on screen.//Note: If the screen is part of a virtual desktop of multiple screens,//the window will not move automatically to screen.//To place the window relative to the screen,//use the screen's topLeft() position.static QWidget *createWindowContainer(QWindow *       window,QWidget *       parent = nullptr,Qt::WindowFlags flags  = Qt::WindowFlags()   );//创建一个 QWidget,使其能够将 window 嵌入基于 QWidget 的应用程序中。//窗口容器作为 parent 的子容器创建,并带有窗口标志 flags。//-旦窗口被嵌入容器,容器将控制窗口的几何形状和可见性。//不建议在嵌入窗口上显式调用QWindow::setGeometry()、QWindow:://show()或QWindow::hide()函数。//容器接管 window 的所有权。可以通过调用 QWindow::setParent()将窗口从窗口容器中移除。//窗口容器作为它所属的顶层窗口的本地子窗口被附加。//当一个窗口容器被用作QAbstractScrollArea或OMdiArea的子窗口时,//它会为其父级链中的每个小部件创建本地窗口,以便在这种使用情况下进行适当的堆叠和剪切。//为窗口容器创建本地窗口也允许进行适当的堆叠和剪切。这必须在显示窗口容器之前完成。//具有许多本地子窗口的应用程序可能会遇到性能问题。//窗口容器存在一些已知的限制://堆叠顺序:嵌入式窗口将作为不透明的盒子堆叠在widget层次结构之上。//              多个重叠窗口容器实例的堆叠顺序未定义。//渲染集成:窗口容器与QGraphicsProxyWidget、QWidget:render()或类似功能不兼容。//焦点处理:可以让窗口容器实例具有任何焦点策略,并通过调用 QWindow:requestActivate()//将焦点委派给窗口。但是,从 QWindow 实例返回到正常的焦点链将由 QWindow 实例实现本身决定。//例如,当进入具有标签焦点的基于 Qt Quick 的窗口时,//再次按下标签很可能只会循环在 QML应用程序内部。//此外,QWindow::requestActivate()实际上是否给予窗口焦点,取决于平台。//在基于QWidget的应用程序中使用多个窗口容器实例会极大地损害应用程序的整体性能。Q_SIGNALS:  //信号函数void windowTitleChanged(const QString &title);void windowIconChanged (const QIcon &icon);void windowIconTextChanged(const QString &iconText);void customContextMenuRequested(const QPoint &pos);//当小部件的 contextMenuPolicy设置为Ot::CustomContextMenu,//并且用户请求在小部件上显示上下文菜单时,会发出此信号。
//pos是小部件接收到的上下文菜单事件的坐标位置。通常,这是在小部件坐标中。该规则的一个例外
//是OAbstractScrollArea及其子类,它们将上下文菜单事件映射到视口 viewport()坐标的位置。protected:// Event handlersbool event(QEvent *event) override;//重新实现: QObject::event(OEvent *e) 这是主要的事件处理程序;它处理事件event。//您可以在子类中重新实现此函数,但建议使用专门的事件处理程序之-//按键和释放事件的处理方式与其他事件不同。event()检查Tab和 Shift+Tab,并尝试适当地移动焦点。//如果没有小部件可以移动焦点(或者按键不是Tab或Shift+Tab),event()会调用keyPressEvent()。//鼠标和触控板事件的处理也稍微特殊:只有当小部件被启用时,//event()才会调用专门的处理器如 mousePressEvent();否则,它将丢弃事件。//如果事件被识别,此函数返回true,否则返回false。//如果被识别的事件被接受(参见QEvent::accepted),则//任何进一步的处理,如事件传播到父控件,都会停止。virtual void mousePressEvent      (QMouseEvent *event);virtual void mouseReleaseEvent    (QMouseEvent *event);virtual void mouseDoubleClickEvent(QMouseEvent *event);virtual void mouseMoveEvent       (QMouseEvent *event);#if QT_CONFIG(wheelevent)  //是有这个宏定义的virtual void wheelEvent(QWheelEvent *event);
#endifvirtual void keyPressEvent  (QKeyEvent *event);virtual void keyReleaseEvent(QKeyEvent *event);virtual void focusInEvent (QFocusEvent *event);virtual void focusOutEvent(QFocusEvent *event);virtual void enterEvent(QEnterEvent *event);virtual void leaveEvent(QEvent *event);virtual void paintEvent (QPaintEvent *event);virtual void resizeEvent(QResizeEvent *event);virtual void moveEvent  (QMoveEvent *event);virtual void closeEvent (QCloseEvent *event);#ifndef QT_NO_CONTEXTMENUvirtual void contextMenuEvent(QContextMenuEvent *event);
#endif#if QT_CONFIG(tabletevent)  //有这个宏定义的virtual void tabletEvent(QTabletEvent *event);
#endif#ifndef QT_NO_ACTION  //此函数存在的virtual void actionEvent(QActionEvent *event);
#endif#if QT_CONFIG(draganddrop)  //是有此定义的 drag_and_drop//当拖动正在进行且鼠标进入此小部件时,将调用此事件处理程序。// The event is passed in the event parameter.//如果事件被忽略,则小部件将不会接收到任何拖移事件。virtual void dragEnterEvent(QDragEnterEvent *event);virtual void dragMoveEvent (QDragMoveEvent  *event);//如果正在执行拖放操作,并且满足以下条件之一时,将调用此事件处理程序:光标进入此小部件、//光标在此小部件内移动或在此小部件获得焦点时按下键盘上的修改键。事件通过事件参数传递。// The event is passed in the event parameter.virtual void dragLeaveEvent(QDragLeaveEvent *event);//当拖动正在进行且鼠标离开此小部件时,将调用此事件处理程序。virtual void dropEvent     (QDropEvent  *event);//This event handler is called when the drag is dropped on this widget.#endif//这个事件处理程序可以在子类中重新实现,以接收在 event参数中传递的 widget显示事件。//非自发的显示事件在显示之前立即发送给小部件。窗口的自发显示事件随后交付。//注:当窗口系统的映射状态发生变化时,小部件会接收到自发的显示和隐藏事件,例如,//当用户最小化窗口时接收到自发的隐藏事件,当窗口恢复时接收到自发的显示事件。//在接收到自发的隐藏事件之后,小部件在isVisible()的意义上仍然被认为是可见的。virtual void showEvent(QShowEvent *event);virtual void hideEvent(QHideEvent *event);//这个事件处理程序可以在子类中重新实现,以接收widget隐藏事件。事件在 event参数中传递。//隐藏事件在它们被隐藏后立即发送给小部件。//This special event handler can be reimplemented in a subclass to//receive native platform events identified by//eventType which are passed in the message parameter.//In your reimplementation of this function,//if you want to stop the event being handled by Qt,//return true and set result. The result parameter has meaning only on Windows.//If you return false, this native event is passed back to Qt,//which translates the event into a Qt event and sends it to the widget.virtual bool nativeEvent( const QByteArray &eventType,void *message, qintptr *result);//Note: Events are only delivered to this event handler//if the widget has a native window handle.//Note: This function superseedes取代 the event filter functions x11Event(),//winEvent() and macEvent() of Qt 4.// Misc. protected functionsvirtual void changeEvent(QEvent * event);//This event handler can be reimplemented to handle state changes.//The state being changed in this event can be retrieved 检索//through the event supplied.//重新实现: QPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const。//内部实现虚拟 QPaintDevice::metric()函数。     m是获取的度量。int metric(PaintDeviceMetric) const override;//初始化 painter 笔、背景和字体与给定的小部件相同。//当在QWidget上打开绘图器时,会自动调用此函数。void initPainter(QPainter * painter) const override;QPaintDevice *redirected(QPoint * offset) const override; //无定义QPainter *sharedPainter() const override; //无注释virtual void inputMethodEvent(QInputMethodEvent * event);//对于事件事件,此事件处理程序可以在子类中重新实现以接收输入法合成事件。//当输入法状态更改时,将调用此处理程序。//注意,在创建自定义文本编辑小部件时,必须显式地设置Qt::WAInputMethodEnabled窗口属性//(使用setAttribute()函数),以便接收输入法事件。//默认实现会调用event->ignore(),这将拒绝输入方法事件。//请参阅QInputMethodEvent文档以获取更多信息。
//***********************************
//protected:  以上结束了 protected 标识符public://此方法仅适用于输入小部件。输入法使用它来查询小部件的一组属性,//以便能够支持复杂的输入法操作,如支持周围文本和重新转换。virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const;//Q_PROPERTY(Qt::InputMethodHints inputMethodHints//              READ inputMethodHints WRITE setInputMethodHints)Qt::InputMethodHints inputMethodHints() const;void              setInputMethodHints(Qt::InputMethodHints hints);protected Q_SLOTS: //信号的槽函数//更新小部件的微聚焦,并通知输入法 query指定的状态已更改。void updateMicroFocus(Qt::InputMethodQuery query = Qt::ImQueryAll);protected:  //开始本基类的 protected 函数//Creates a new widget window.//The parameters window, initializeWindow, and//destroyOldWindow are ignored in Qt 5.void create(WId = 0, bool initializeWindow = true,bool destroyOldWindow = true);void destroy(bool destroyWindow = true,bool destroySubWindows = true);//Frees up window system resources.//Destroys the widget window if destroyWindow is true.//destroy() calls itself recursively for all the child widgets,//passing destroySubWindows for the destroyWindow parameter.//To have more control over destruction of subwidgets,//destroy subwidgets selectively first.  析构函数//This function is usually called from the QWidget destructor.//找到一个新的小部件,将键盘焦点分配给Tab和Shift+Tab,//如果找到新的小部件,则返回true,否则返回false。//如果next为真,则该函数向前搜索,如果next为假,则它向后搜索。//有时,您可能需要重新实现此函数。例如,Web 浏览器可能会重新实现它,//以向前或向后移动其“当前活动链接”,//并在到达“页面”上的最后一个或第一个链接时调用focusNextPrevChild()//子控件在其父控件上调用focusNextPrevChild()函数,但只有包含子控件的窗口决定重定向焦点的位置。//通过为对象重写此函数,您可以控制所有子控件的焦点遍历。virtual bool focusNextPrevChild(bool next); //下面两个函数依赖本函数inline  bool focusNextChild(){ return     focusNextPrevChild(true) ; } //调用上面的函数inline bool focusPreviousChild(){ return     focusNextPrevChild(false); }friend class QDataWidgetMapperPrivate; // for access to focusNextPrevChildprotected: //本类的构造函数QWidget(QWidgetPrivate &d, QWidget* parent, Qt::WindowFlags f);
private:void setBackingStore(QBackingStore *store);bool testAttribute_helper(Qt::WidgetAttribute) const;QLayout *takeLayout();friend class QBackingStoreDevice;friend class QWidgetRepaintManager;friend class QApplication;friend class QApplicationPrivate;friend class QGuiApplication;friend class QGuiApplicationPrivate;friend class QBaseApplication;friend class QPainter;friend class QPainterPrivate;friend class QPixmap; // for QPixmap::fill()friend class QFontMetrics;friend class QFontInfo;friend class QLayout;friend class QWidgetItem;friend class QWidgetItemV2;friend class QX11PaintEngine;friend class QWin32PaintEngine;friend class QShortcutPrivate;friend class QWindowSurface;friend class QGraphicsProxyWidget;friend class QGraphicsProxyWidgetPrivate;friend class QStyleSheetStyle;friend struct QWidgetExceptionCleaner;friend class QWidgetWindow;friend class QAccessibleWidget;friend class QAccessibleTable;friend class QAccessibleTabButton;
#ifndef QT_NO_GESTURESfriend class QGestureManager;friend class QWinNativePanGestureRecognizer;
#endif // QT_NO_GESTURESfriend class QWidgetEffectSourcePrivate;#ifdef Q_OS_MACfriend bool qt_mac_is_metal(const QWidget *w);
#endiffriend Q_WIDGETS_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget);friend Q_WIDGETS_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget);}; //完结啦 class QWidget : public QObject, public QPaintDeviceQ_DECLARE_OPERATORS_FOR_FLAGS(QWidget::RenderFlags)#ifndef Q_QDOC
template <> inline //此处重载了类型转换函数 qobject_cast
QWidget * qobject_cast<QWidget*>(QObject * o)
{if (!o || !o->isWidgetType())    return nullptr;return static_cast<QWidget *>(o); //可见,QT 里的本转换等同于 static_cast转换
}template <> inline const  //进行常量指针转换
QWidget *qobject_cast<const QWidget *>(const QObject * o)
{if (!o || !o->isWidgetType()) return nullptr;return static_cast<const QWidget *>(o);
}
#endif // !Q_QDOC#if QT_DEPRECATED_SINCE(6, 1)
inline bool QWidget::isTopLevel() const
{ return (windowType() & Qt::Window); }
#endif#define QWIDGETSIZE_MAX ((1<<24)-1)#ifndef QT_NO_DEBUG_STREAM //说明支持这样的写法 qDebug() << (QWidget *)打印指针
Q_WIDGETS_EXPORT QDebug operator<<(QDebug, const QWidget *);
#endif
//既然重载了此函数,就说明不是打印内存地址了,示例:Widget(0xcc66dff9a0, name="Widget")QT_END_NAMESPACE#endif // QWIDGET_H

(3)

谢谢

相关文章:

QT6 源(37):界面组件的总基类 QWidget 的源码阅读(下,c++ 代码部分)

&#xff08;1&#xff09; QT 在 c 的基础上增加了自己的编译器&#xff0c;以支持元对象系统和 UI 界面设计&#xff0c;有 MOC 、 UIC 等 QT 自己的编译器。本节的源代码里&#xff0c;为了减少篇幅&#xff0c;易于阅读&#xff0c;去除了上篇中的属性部分&#xff0c; 上篇…...

进程与线程:01 CPU管理的直观想法

多进程图像与操作系统核心 好从今天开始&#xff0c;我们就要开始学习操作系统&#xff0c;最核心的图像是多进程图像。前面我们讲过&#xff0c;多进程图像对操作系统来说非常重要&#xff0c;它是操作系统的核心图像。明白了它以后&#xff0c;对于理解操作系统的一大部分内…...

19. git reflog

基本概述 git reflog 的作用是&#xff1a;查看本地仓库的引用日志&#xff08;reference log&#xff09;&#xff0c;例如分支、HEAD等。它可以帮助你找回误删的提交、恢复被覆盖的分支&#xff0c;或回溯操作历史。 基本用法 1.查看完整的reflog git reflog这会显示所有…...

C语言 —— 铭纹织构未诞之镜 - 预处理详解

目录 1. 什么是预处理&#xff08;预编译&#xff09; ​编辑 2. 预定义符号 3. #define 定义常量 4. #define定义宏 5. 带副作用的宏参数 6. 宏替换的规则 7. 宏和函数的对比 8. #和## 8.1 #运算符 8.2 ## 运算符 9. #undef 10. 条件编译 1. 什么是预处理&#xf…...

Linux 文件系统目录结构详解

Linux 文件系统目录结构详解 Linux 文件系统遵循 Filesystem Hierarchy Standard (FHS) 标准&#xff0c;定义了各个目录的用途和文件存放规则。无论是开发者、运维工程师还是普通用户&#xff0c;理解这些目录的作用都至关重要。本文将全面解析 Linux 的目录结构&#xff0c;…...

2025-4-19 情绪周期视角复盘(mini)

我本以为市场进化规律下产生龙头战法的末法时代导致情绪周期逐步混乱或者说混沌期漫长。所谓的市场进化无非也是量化的发展和各类资金逐步量化化的充分博弈下的结果。通过逐步向上思考发现&#xff0c;不仅仅我们的市场是处于一个存量的时代背景&#xff0c;重要的是我们的思维…...

-实用类-

1. API是什么 2.什么是枚举 &#xff01;有点类似封装&#xff01; 2.包装类 注意&#xff1a; 1.Boolean类构造方法参数为String类型时&#xff0c;若该字符串内容为true(不考虑大小写)&#xff0c;则该Boolean对象表示true&#xff0c;否则表示false 2.当包装类构造方法参…...

Unity3D仿星露谷物语开发36之锄地动画2

1、目标 当角色锄地之后&#xff0c;地面会显示开垦后的样貌。 2、思路 上一篇中&#xff0c;虽然角色dig了hoe&#xff0c;同时grid属性也改变了&#xff0c;但是没有任何可视化的反馈。我们现在将添加新的功能&#xff0c;动态地将"dug ground"瓷砖添加到"…...

【备考高项】模拟预测题(一)案例分析及答案详解

更多内容请见: 备考信息系统项目管理师-专栏介绍和目录 文章目录 试题一【问题 1】(10分)【问题 2】(5分)【问题 3】(4分)【问题 4】(6分)试题二【问题 1】(12分)【问题 2】(3分)【问题 3】(6分)【问题 4】(4分)试题三【问题 1】(4分)【问题 2】(10分)【问题 3】…...

7、sentinel

控制台访问地址&#xff1a;http://localhost:8080/ 依赖 <dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> </dependency>配置文件 spring:cloud:sentinel:transpo…...

状态管理最佳实践:Provider使用技巧与源码分析

状态管理最佳实践&#xff1a;Provider使用技巧与源码分析 前言 Provider是Flutter官方推荐的状态管理解决方案&#xff0c;它简单易用且功能强大。本文将从实战角度深入讲解Provider的使用技巧和源码实现原理&#xff0c;帮助你更好地在项目中应用Provider进行状态管理。 基…...

INFINI Console 系统集群状态异常修复方案

背景介绍 运行 INFINI Console 1.29.0 和 1.29.1 版本 的用户在 新初始化 平台后可能会遇到一个特定问题。如果后台的系统 Easysearch/Elasticsearch 集群&#xff08;存储 Console 元数据的集群&#xff0c;通常名为 .infini_cluster 或类似名称&#xff09;包含超过一个节点…...

Spring Boot自动装配原理(源码详细剖析!)

什么是Spring Boot的自动装配&#xff1f; 自动装配是Spring Boot的核心功能&#xff0c;它能够根据应用程序的依赖和配置自动配置Spring。这意味着我们只需要添加大量的依赖&#xff0c;Spring Boot就能自动完成配置&#xff0c;减少了人工配置的工作量。 自动装配的核心注…...

大数据驱动的高效能量管理:智能优化与实践探索

大数据驱动的高效能量管理:智能优化与实践探索 在全球能源需求不断增长的背景下,如何提高能源利用效率成为各行业关注的焦点。传统的能源管理方式往往依赖固定规则和人工监测,难以适应复杂多变的应用场景。而大数据技术的兴起,为能量管理提供了新的解决方案——通过数据驱…...

《银行数字化风控-业务于实战》读后知识总结

引言 在金融科技高速发展的今天&#xff0c;银行的风控体系正经历从“人工经验驱动”向“数据智能驱动”的深刻变革。《银行数字化风控-业务于实战》一书以实战为导向&#xff0c;系统性地剖析了数字化风控的核心逻辑、技术实现路径及业务落地方法论。作为深耕风控领域多年的从…...

初级达梦dba的技能水准

在x86环境&#xff08;windows、linux&#xff09;安装单机软件&#xff0c;安装客户端创建过至少20套数据库&#xff0c;优化参数并更新过正式许可会用逻辑导出导入以及dmrman备份了解manager工具的使用配置sqllog日志&#xff0c;并能解释输出内容能够分析因磁盘空间不足、内…...

C++初阶-类和对象(中)

目录 1.类的默认成员函数 2.构造函数&#xff08;难度较高&#xff09; ​编辑 ​编辑 ​编辑 3.析构函数 4.拷贝构造函数 5.赋值运算符重载 5.1运算符重载 5.2赋值运算符重载 6.取地址运算符重载 6.1const成员函数 6.2取地址运算符重载 7.总结 1.类的默认成员函数…...

Linux网络UDP与TCP

基础知识 传输层 负责数据能够从发送端传输接收端。 端口号(Port)标识了一个主机上进行通信的不同的应用程序; 在 TCP/IP 协议中, 用 “源 IP”, “源端口号”, “目的 IP”, “目的端口号”, “协议号” 这样一个五元组来标识一个通信(可以通过 netstat -n 查看); 端口号范…...

23、.NET和C#有什么区别?

1、定义与范畴 .NET 定义 .NET 是一个由微软开发的开发平台&#xff08;Platform&#xff09;&#xff0c;它提供了一套完整的工具、库和运行时环境&#xff0c;用于构建各种类型的应用程序。 范畴 包括 .NET Framework、.NET Core&#xff08;现称为 .NET 5 及以上版本&a…...

Qt6离线安装过程

Qt6离线安装过程 说明解决方案联网笔记本安装qt6拷贝到离线电脑修改qtenv2.bat文件 说明 现在qt6已经不能通过离线的方式下载安装包安装了&#xff0c;只能通过登陆的方式在线安装&#xff0c;但是&#xff0c;又有离线安装运行的需求&#xff0c;那么怎么办呢&#xff1f;请跟…...

如何在 Go 中创建和部署 AWS Lambda 函数

AWS Lambda 是一个无服务器计算平台&#xff0c;您可以使用自己喜欢的编程语言编写代码&#xff0c;无需担心设置虚拟机。 您只需为 Lambda 函数的调用次数和运行时间&#xff08;毫秒&#xff09;付费。 我们大多数人都了解 JavaScript 和 Python&#xff0c;但它们的内存效率…...

【后端】【Django】Django 模型中的 `clean()` 方法详解:数据校验的最后防线

Django 模型中的 clean() 方法详解&#xff1a;数据校验的最后防线 在 Django 的模型系统中&#xff0c;我们经常使用字段级别的校验器&#xff08;validators&#xff09;来约束某个字段的取值范围。但当校验逻辑涉及多个字段之间的关系时&#xff0c;字段级别校验就无能为力…...

内存管理详解(曼波脑图超详细版!)

(✪ω✪)曼波来解答三连问啦&#xff01;准备好内存知识大礼包了吗&#xff1f;(≧∇≦)&#xff89; ━━━━━━━━━━━━━ ฅ^•ω•^ฅ ━━━━━━━━━━━ 一、内存分配详解 (๑>ᴗ<๑) (1) 栈内存 → 像便签纸&#x1f4dd; void calculate() {int a …...

【2025最新redis数据结构之Hypeloglog介绍】关于Hypeloglog

HyperLogLog (HLL) 算法深度解析 一、HLL 基本概念 HyperLogLog 是一种用于基数统计&#xff08;distinct counting&#xff09;的概率算法&#xff0c;能够在极小内存占用下&#xff08;通常只需几KB&#xff09;估算巨大数据集的基数&#xff08;不重复元素数量&#xff09…...

软考复习——知识点软件开发

开发模型 瀑布模型 各个活动规定为线性顺序连接的若干阶段的模型。是一种理想的现象开发模型&#xff0c;缺乏灵活性&#xff0c;无法理解软件需求不明确或不准确的问题。适用于需求明确的项目。 演化模型 从初始的原型逐步演化成最终软件产品&#xff0c;特别适用于对软件…...

关于AI:记忆、身份和锁死

作者&#xff1a;John Battelle 当生成式AI迎来投资热潮、产品发布和炒作高峰时&#xff0c;我们大多数人在奔向“下一个大事件”的过程中&#xff0c;忽略了一个深层次的缺陷。我们现在主流的AI产品和服务&#xff08;比如OpenAI、Google和Microsoft的产品&#xff09;都是通过…...

2024新版仿蓝奏云网盘源码,已修复已知BUG,样式风格美化,可正常运营生产

说起网盘源码&#xff0c;网络上出现的也很多&#xff0c;不过可真正正能够用于运营的少之又少。今天将的蓝奏云网盘源码&#xff0c;其实网络上也有&#xff0c;不过是残缺版&#xff0c;bug很多。我今天分享的仿蓝奏云模板是经过长时间测试修复后的源码&#xff0c;源码实测可…...

OJ - 设计循环队列

622. 设计循环队列 - 力扣&#xff08;LeetCode&#xff09; 循环队列是一种线性数据结构&#xff0c;其操作表现基于 FIFO&#xff08;先进先出&#xff09;原则&#xff0c;并且队尾被连接在队首之后以形成一个循环。它也被称为“环形缓冲器”。 循环队列的一个好处是我们可…...

实战指南:封装Faster-Whisper为FastAPI接口并实现高并发处理-附整合包

实战指南&#xff1a;封装Faster-Whisper为FastAPI接口并实现高并发处理-附整合包 「faster-whisper」 链接&#xff1a;https://pan.quark.cn/s/d4ddffb1b196 标题下面提供一个完整的示例&#xff0c;说明如何使用 FastAPI 封装 faster-whisper 接口&#xff0c;对外提供 RES…...

011数论——算法备赛

素数筛 给定n, 求2~n内的所有素数 埃氏筛 利用素数的定义&#xff0c; 输出素数2&#xff0c;然后筛掉2的倍数&#xff0c;得 {2,3,5,7,9,11,13&#xff0c;…}输出素数3&#xff0c;然后筛掉3的倍数&#xff0c;得 {2,3,5,7,11,13&#xff0c;…} 继续上述步骤&#xff0…...

C语言之机房机位预约系统

&#x1f31f; 嗨&#xff0c;我是LucianaiB&#xff01; &#x1f30d; 总有人间一两风&#xff0c;填我十万八千梦。 &#x1f680; 路漫漫其修远兮&#xff0c;吾将上下而求索。 C语言之机房机位预约系统 目录 博客&#xff1a;机房机位预约系统设计与实现 系统功能概述…...

中间件--ClickHouse-14--案例-3-其他案例思路概述

1、广告投放效果分析 案例背景&#xff1a; 一家广告平台需要分析广告的点击、曝光、转化等数据&#xff0c;以优化广告投放策略并提升 ROI&#xff08;投资回报率&#xff09;。 解决方案&#xff1a; 数据接入&#xff1a;将广告投放相关的数据&#xff08;如曝光、点击、…...

saas是什么?它做什么用的。及和Paas和laas有什么区别

Saas是什么&#xff1f;它做什么用的。及和Paas和laas有什么区别 提示&#xff1a;帮帮志会陆续更新非常多的IT技术知识&#xff0c;希望分享的内容对您有用。本章分享的是行业内容。前后每一小节的内容是存在的有&#xff1a;学习and理解的关联性&#xff0c;希望对您有用~ 文…...

Qt基础005(文件操作后续)

文章目录 QFileDialogQFileDialog打开开发案例QFileDialog保存开发案例实现文件打开功能开发流程打开功能优化 QComboBoxQListExtraSelection 简介 QFileDialog QFileDialog打开开发案例 #include <QApplication> #include <QFileDialog> #include <QStringLi…...

松灵Cobot Magic双臂具身遥操机器人(基于ROS的定位建图与协同导航技术)

摘要 本文以CobotMagic可移动协作机器人为研究对象&#xff0c;从硬件架构设计、软件系统架构、多传感器融合定位建图系统、智能导航系统协同机制四个维度&#xff0c;深入解析机器人系统工作原理。重点研究多传感器融合定位建图系统实现原理&#xff0c;结合实测数据验证系统…...

AI——神经网络以及TensorFlow使用

文章目录 一、TensorFlow安装二、张量、变量及其操作1、张量Tensor2、变量 三、tf.keras介绍1、使用tf.keras构建我们的模型2、激活函数1、sigmoid/logistics函数2、tanh函数3、RELU函数4、LeakReLu5、SoftMax6、如何选择激活函数 3、参数初始化1、bias偏置初始化2、weight权重…...

实现对象之间的序列化和反序列化

1.什么是序列化&#xff1f; 在项目的开发中&#xff0c;为了让前端更好的分析后端返回的结果&#xff0c;我们一般会将返回的信息进行序列化&#xff0c;序列化就是将返回对象的状态信息转换为一种标准化的格式&#xff0c;方便在网络中传输也方便打印日志时号观察&#xff0…...

QML中日期处理类

在 QML 中处理日期和时间主要使用 JavaScript 的 Date 对象以及 Qt 提供的一些相关功能。以下是常用的日期处理方式&#xff1a; 1. JavaScript Date 对象 QML 可以直接使用 JavaScript 的 Date 对象&#xff1a; qml // 创建当前日期时间 var currentDate new Date()// 创…...

基于docker-java封装的工具类

基于docker-java封装的工具类 背景环境工具类 背景 写OJ系统时需要用docker作为代码沙箱使用&#xff0c;顺手封装了一个工具类&#xff0c;给自己做个笔记&#xff0c;如果可以的话也希望帮助到其他人。 环境 docker 26.1.4docker-java 3.4.2docker-java-transport-httpcli…...

windows docker desktop 无法访问容器端口映射

为什么使用docker desktop访问映射的端口失败&#xff0c;而其端口对应的服务是正常的&#xff1f; 常见问题&#xff0c;容器的防火墙没有关闭&#xff01;&#xff01;&#xff01; 以centos7为例&#xff0c;默认情况下防火墙处于开启状态&#xff1a; 这下访问就OK了...

ReentrantReadWriteLock读写锁

一、锁的分类 这里不会对Java中大部分的分类都聊清楚&#xff0c;主要把 **互斥&#xff0c;共享** 这种分类聊清楚。 Java中的互斥锁&#xff0c;synchronized&#xff0c;ReentrantLock这种都是互斥锁。一个线程持有锁操作时&#xff0c;其他线程都需要等待前面的线程释放锁…...

Vue.js 入门教程

Vue.js 入门教程 Vue.js 是一款非常流行的前端 JavaScript 框架&#xff0c;适用于构建用户界面。它的设计思想是尽可能简单、灵活&#xff0c;易于与其他库或现有项目整合。本文将从最基础的概念开始&#xff0c;逐步引导你学习 Vue.js。 一、Vue.js 基础概念 1.1 什么是 V…...

解决Docker 配置 daemon.json文件后无法生效

vim /etc/docker/daemon.json 在daemon中配置一下dns {"registry-mirrors": ["https://docker.m.daocloud.io","https://hub-mirror.c.163.com","https://dockerproxy.com","https://docker.mirrors.ustc.edu.cn","ht…...

wpf stylet框架 关于View与viewmodel自动关联绑定的问题

1.1 命名规则 Aview 对应 AVIewModel, 文件夹 views 和 viewmodels 1.2 需要注册服务 //RootViewModel是主窗口 public class Bootstrapper : Bootstrapper<RootViewModel>{/// <summary>/// 配置IoC容器。为数据共享创建服务/// </summary…...

车载测试用例开发-如何平衡用例覆盖度和测试效率的方法论

1 摘要 在进行车载测试用例编写时&#xff0c;会遇到多个条件导致用例排列组合爆炸的情况&#xff0c;但是为了产品测试质量&#xff0c;我们又不得不保证用例设计的需求覆盖度&#xff0c;这样又会使得测试周期非常长。我们如何平衡效率和测试质量&#xff1f;本文进行了一些…...

leetcode(01)森林中的兔子

今天开始记录刷题的过程&#xff0c;每天记录自己刷题的题目和自己的解法&#xff0c;欢迎朋友们给出更多更好的解法。 森林中的兔子 森林中有未知数量的兔子&#xff0c;提问其中若干只兔子“还有多少只兔子与你&#xff08;被提问的兔子&#xff09;颜色相同”。将答案收集到…...

人工智能-机器学习其他技术(决策树,异常检测,主成分分析)

决策树 一种对实例进行分类的树形结构&#xff0c;通过多层判断区分目标所属类别 本质&#xff1a;通过多层判断&#xff0c;从训练数据集中归纳出一组分类规则 优点&#xff1a; 计算量校&#xff0c;运算速度快 易于理解 缺点&#xff1a; 忽略属性间的相关性 样本分布不均时…...

AIGC通信架构深度优化指南

AIGC通信架构深度优化指南 标题&#xff1a;《百亿参数大模型如何高效通信&#xff1f;揭秘AIGC系统的协议层设计艺术》 副标题&#xff1a;从分布式训练到多模态推理&#xff0c;构建高可靠AI通信系统 1. AIGC典型通信场景 1.1 分布式模型训练参数同步 sequenceDiagram训练…...

精益数据分析(7/126):打破创业幻想,拥抱数据驱动

精益数据分析&#xff08;7/126&#xff09;&#xff1a;打破创业幻想&#xff0c;拥抱数据驱动 在创业的道路上&#xff0c;我们都怀揣着梦想&#xff0c;但往往容易陷入自我编织的幻想中。我希望通过和大家一起学习《精益数据分析》&#xff0c;能帮助我们更清醒地认识创业过…...

Android Gradle多渠道打包

目录 1.多渠道打包是什么2.为什么需要多渠道打包3.多渠道配置VariantproductFlavorsbuildTypes 3.构建变体组合关于组合 4.渠道过滤5.渠道资源资源文件资源合并规则代码文件SourceSets 6. 渠道依赖项7.渠道统计meta-dataBuildConfig 8.管理渠道 1.多渠道打包是什么 多聚道打包…...