QPoint和QSize

QPoint类表示平面上的点,包含x和y坐标,可用作矢量进行加减运算。QSize则定义了二维对象的大小,包括宽度和高度,两者都支持多种操作,如设置、比较和流操作,常用于Qt图形和图像处理。
摘要由CSDN通过智能技术生成

QPoint类定义了平面上的一个点:

一个点由一个x坐标和一个y坐标确定。

坐标类型是QCOORD(一个32位整数)。QCOORD的最小值是QCOORD_MIN(-2147483648),最大值是QCOORD_MAX(2147483647)。

坐标可以通过函数x()和

下面这段代码什么意思class CaptureDialog : public QWidget { Q_OBJECT public: explicit CaptureDialog(QWidget *parent = 0); ~CaptureDialog(); void region(const QPoint &cursorGlobalPoint); void mouseMoveEvent(QMouseEvent *); void mouseReleaseEvent(QMouseEvent *); void mousePressEvent(QMouseEvent *); void setButton(); void setPixmap(QPixmap pixmap); void setGroupBoxSize(QSize size); QRect getNormalRect(){return normalRect; } private: enum Direction { UP=0, DOWN=1, LEFT, RIGHT, LEFTTOP, LEFTBOTTOM, RIGHTBOTTOM, RIGHTTOP, NONE }; const int PADDING ; const int buttonWidth ; const int buttonHeight ; QRect normalRect; //保存最大化以前的大小,因为最小化以前this->rect()已经变成了全屏时的rect() bool isLeftPressDown; // 判断左键是否按下 QPoint dragPosition; // 窗口移动拖动时需要记住的点 Direction dir; // 窗口大小改变时,记录改变方向 QPushButton * closeButton; QPushButton * minimumButton ; QPushButton * maximumButton ; QWidget* groupBox; int fullScreenWidth; int fullScreenHeight; int clickCount; InCaptureLabel * label; QPixmap pixmap; InCaptureWidget* bottomWidget; QLabel * saveDirLable; QLineEdit *lineEdit; QPushButton * browseButton; QLabel* saveTypeLabel; QComboBox * typeComboBox; QLabel* saveNameLabel; QLineEdit * saveNameLineEdit; QPushButton * saveButton; QPushButton * saveToClipBoard; static QPoint Position; QSize videoWidgetSize; public slots: void slotSignalMovePoint(QPoint point); void slotBottomWidgetMouseLeftDown(); void slotSaveBottonClicked(); void slotSaveToClipBoard(); void slotBrowseButtonClicked(); };
05-05
如何将以下代码转成pyside6的 #include <QtGui> class GripLabel: public QLabel { Q_OBJECT public: GripLabel(QString const& title, QWidget* parent = 0) : QLabel(title, parent), resizing(false), gripSize(10, 10) { // Prevent the widget from disappearing altogether // Bare minimum would be gripSize setMinimumSize(100, 30); } QSize sizeHint() const { return minimumSize(); } protected: bool mouseInGrip(QPoint mousePos) { // "handle" is in the lower right hand corner return ((mousePos.x() > (width() - gripSize.width())) && (mousePos.y() > (height() - gripSize.height()))); } void mousePressEvent(QMouseEvent *e) { // Check if we hit the grip handle if (mouseInGrip(e->pos())) { oldPos = e->pos(); resizing = true; } else { resizing = false; } } void mouseMoveEvent(QMouseEvent *e) { if (resizing) { // adapt the widget size based on mouse movement QPoint delta = e->pos() - oldPos; oldPos = e->pos(); setMinimumSize(width()+delta.x(), height()+delta.y()); updateGeometry(); } } void paintEvent(QPaintEvent *e) { QLabel::paintEvent(e); QPainter p(this); p.setPen(Qt::red); p.drawRect(width()-gripSize.width(), height()-gripSize.height(), gripSize.width(), gripSize.height()); } private: bool resizing; QSize gripSize; QPoint oldPos; }; sample 主要: #include "griplabel.h" int main(int argc, char **argv) { QApplication app(argc, argv); QWidget *w = new QWidget; QPushButton *b = new QPushButton("button"); GripLabel *l = new GripLabel("Hello"); QHBoxLayout *y = new QHBoxLayout; y->addWidget(b); y->addWidget(l); y->setSizeConstraint(QLayout::SetFixedSize); w->setLayout(y); w->show(); return app.exec(); }
05-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大王算法

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值