qt 实现窗口拉伸
重寫
protected:bool nativeEvent(const QByteArray &eventType, void *message, long *result);
函數(shù)實現(xiàn) bool Widget::nativeEvent(const QByteArray &eventType, void *message, long *result) {Q_UNUSED(eventType)MSG *param = static_cast<MSG *>(message);switch (param->message){case WM_NCHITTEST:{int nX = GET_X_LPARAM(param->lParam) - this->geometry().x();int nY = GET_Y_LPARAM(param->lParam) - this->geometry().y();// 如果鼠標(biāo)位于子控件上,則不進(jìn)行處理if (childAt(nX, nY) != NULL)return QWidget::nativeEvent(eventType, message, result);*result = HTCAPTION;// 鼠標(biāo)區(qū)域位于窗體邊框,進(jìn)行縮放if ((nX > 0) && (nX < m_nBorder))*result = HTLEFT;if ((nX > this->width() - m_nBorder) && (nX < this->width()))*result = HTRIGHT;if ((nY > 0) && (nY < m_nBorder))*result = HTTOP;if ((nY > this->height() - m_nBorder) && (nY < this->height()))*result = HTBOTTOM;if ((nX > 0) && (nX < m_nBorder) && (nY > 0)&& (nY < m_nBorder))*result = HTTOPLEFT;if ((nX > this->width() - m_nBorder) && (nX < this->width())&& (nY > 0) && (nY < m_nBorder))*result = HTTOPRIGHT;if ((nX > 0) && (nX < m_nBorder)&& (nY > this->height() - m_nBorder) && (nY < this->height()))*result = HTBOTTOMLEFT;if ((nX > this->width() - m_nBorder) && (nX < this->width())&& (nY > this->height() - m_nBorder) && (nY < this->height()))*result = HTBOTTOMRIGHT;return true;}}return QWidget::nativeEvent(eventType, message, result);}
函數(shù)實現(xiàn) bool Widget::nativeEvent(const QByteArray &eventType, void *message, long *result) {Q_UNUSED(eventType)MSG *param = static_cast<MSG *>(message);switch (param->message){case WM_NCHITTEST:{int nX = GET_X_LPARAM(param->lParam) - this->geometry().x();int nY = GET_Y_LPARAM(param->lParam) - this->geometry().y();// 如果鼠標(biāo)位于子控件上,則不進(jìn)行處理if (childAt(nX, nY) != NULL)return QWidget::nativeEvent(eventType, message, result);*result = HTCAPTION;// 鼠標(biāo)區(qū)域位于窗體邊框,進(jìn)行縮放if ((nX > 0) && (nX < m_nBorder))*result = HTLEFT;if ((nX > this->width() - m_nBorder) && (nX < this->width()))*result = HTRIGHT;if ((nY > 0) && (nY < m_nBorder))*result = HTTOP;if ((nY > this->height() - m_nBorder) && (nY < this->height()))*result = HTBOTTOM;if ((nX > 0) && (nX < m_nBorder) && (nY > 0)&& (nY < m_nBorder))*result = HTTOPLEFT;if ((nX > this->width() - m_nBorder) && (nX < this->width())&& (nY > 0) && (nY < m_nBorder))*result = HTTOPRIGHT;if ((nX > 0) && (nX < m_nBorder)&& (nY > this->height() - m_nBorder) && (nY < this->height()))*result = HTBOTTOMLEFT;if ((nX > this->width() - m_nBorder) && (nX < this->width())&& (nY > this->height() - m_nBorder) && (nY < this->height()))*result = HTBOTTOMRIGHT;return true;}}return QWidget::nativeEvent(eventType, message, result);}
總結(jié)
- 上一篇: 微信公众平台开发新手教程(图文具体解释)
- 下一篇: 329. 矩阵中的最长递增路径