• 大小: 5.56MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-17
  • 语言: C/C++
  • 标签: Qt  调整大小  无边框  

资源简介

详情见我的博客:http://blog.csdn.net/what951006/article/details/52831183 无bug !和windows自带效果一样!且跨平台!

资源截图

代码片段和文件信息

#include “AbsframeLessAutoSize.h“
#include
AbsframeLessAutoSize::AbsframeLessAutoSize(QWidget *parent)
    : QWidget(parent)
{
    m_border=4;
    m_state.MousePressed=false;
    setMinimumSize(400550);
    setMaximumSize(800700);

    setMouseTracking(true);
    setWindowFlags(Qt::framelessWindowHint); //setting windows tool bar icon invisiable
    setSizePolicy(QSizePolicy::ExpandingQSizePolicy::Expanding);
}

void AbsframeLessAutoSize::mouseMoveRect(const QPoint& p)
{
    if(!m_state.IsPressBorder)
    {
        if( p.x()>width()-m_border&&p.y()m_border)//right side
        {
            setCursor(Qt::SizeHorCursor);
            m_curPos= CursorPos::Right;
        }
        else if(p.x()m_border)//left side;
        {
            setCursor(Qt::SizeHorCursor);
            m_curPos= CursorPos::Left;
        }
        else if(p.y()>height()-m_border&&p.x()>m_border&&p.x()        {
            setCursor(Qt::SizeVerCursor);
            m_curPos= CursorPos::Bottom;
        }
        else if(p.y()m_border&&p.x()        {
            setCursor(Qt::SizeVerCursor);
            m_curPos=CursorPos::Top;
        }
//corner
        else if(p.y()width()-m_border)
        {
            setCursor(Qt::SizeBDiagCursor);
            m_curPos=CursorPos::TopRight;
        }

        else if(p.y()        {
            setCursor(Qt::SizeFDiagCursor);
            m_curPos=CursorPos::TopLeft;
        }

        else if(p.x()>m_border&&p.y()>height()-m_border)
        {
            setCursor(Qt::SizeFDiagCursor);
            m_curPos=CursorPos::BottomRight;
        }

        else if(p.x()height()-m_border)
        {
            setCursor(Qt::SizeBDiagCursor);
            m_curPos=CursorPos::BottomLeft;
        }
////
        else
        {
            setCursor(Qt::ArrowCursor);
        }
    }
    else
    {
        switch (m_curPos) {
        case CursorPos::Right:
        {
           int setW=QCursor::pos().x()-x();
           if(minimumWidth()<=setW&&setW<=maximumWidth())
             setGeometry(x()y()setWheight());
            break;
        }
        case CursorPos::Left:
        {
            int setW=x()+width()-QCursor::pos().x();
            int setX=QCursor::pos().x();
            if(minimumWidth()<=setW&&setW<=maximumWidth())
              setGeometry(setXy()setWheight());
             break;
        }
        case CursorPos::Bottom:
        {
            int setH=QCursor::pos().y()-y();
            if(minimumHeight()<=setH&&setH<=maximumHeight())
            setGeometry(x()y()width()setH);
            break;
        }
        case CursorPos::Top:
        {
           int setH=y()-QCursor::pos().y()+height();
           if(minimumHeight()<=setH

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       6952  2016-10-16 16:39  AbsframeLessAutoSizeWidget\AbsframeLessAutoSize.cpp

     文件        850  2016-10-16 16:39  AbsframeLessAutoSizeWidget\AbsframeLessAutoSize.h

     文件   16510464  2016-10-16 16:40  AbsframeLessAutoSizeWidget\AbsframeLessAutoSizeWidget.exe

     文件        390  2016-10-16 09:10  AbsframeLessAutoSizeWidget\AbsframeLessAutoSizeWidget.pro

     文件        203  2016-10-16 09:10  AbsframeLessAutoSizeWidget\main.cpp

     目录          0  2016-10-16 16:41  AbsframeLessAutoSizeWidget

----------- ---------  ---------- -----  ----

             16518859                    6


评论

共有 条评论