手机网站和电脑网站跳转,网站被黑咋样的,软件开发工程师薪资待遇,有了网站源码可以做网站吗提要
窗口用于显示文本信息#xff0c;当窗口的文本信息变长#xff0c;原有窗口的大小不足以显示文本信息。这时就需要一个能够根据窗口要显示的文本信息的长度来调整窗口大小的窗口。
示例
效果图#xff1a; 窗口内容少的时候提示窗口大小#xff0c;当窗口要显示的…提要
窗口用于显示文本信息当窗口的文本信息变长原有窗口的大小不足以显示文本信息。这时就需要一个能够根据窗口要显示的文本信息的长度来调整窗口大小的窗口。
示例
效果图 窗口内容少的时候提示窗口大小当窗口要显示的内容变多提示窗口的大小就会变大。 在窗口过小的时发送调整窗口大小的信号提示窗口收到信号后根据不同的情况做出调整窗口大小。 附上代码
void largeScreenListWidget::setRowColNum(int row, int col)
{m_stuBigScrInfo.bigScreRow row;m_stuBigScrInfo.bigScreCol col;if(row * col 6){emit sigChangedSize(row * col);//发送改变大小的信号}update();
}
connect(this,largeScreenListWidget::sigChangedSize,m_toolTip,ToolTipForm::onChangedSize);提示窗口的ui文件的截图
tooltipform.h
#ifndef TOOLTIPFORM_H
#define TOOLTIPFORM_H#include QWidget/**********类功能描述提示框***********/
namespace Ui {
class ToolTipForm;
}class ToolTipForm : public QWidget
{Q_OBJECTpublic:explicit ToolTipForm(QWidget *parent nullptr);~ToolTipForm();void setToolTipInfo(QString strTip);//设置窗口提示信息void adjustWidSize(int w,int h);//调整窗口的大小w:宽h:高
public slots:void onChangedSize(int count);//接收信号后改变窗口大小count单元格数目
private:Ui::ToolTipForm *ui;
};#endif // TOOLTIPFORM_H
tooltipform.cpp
#include tooltipform.h
#include ui_tooltipform.hToolTipForm::ToolTipForm(QWidget *parent) :QWidget(parent),ui(new Ui::ToolTipForm)
{ui-setupUi(this);//设置窗口为圆角必须设置背景透明和无边框setAttribute(Qt::WA_TranslucentBackground);//设置背景透明setWindowFlags(Qt::WindowTransparentForInput | Qt::ToolTip | Qt::FramelessWindowHint);//窗口仅用于输出不接收任何输入事件
}ToolTipForm::~ToolTipForm()
{delete ui;
}void ToolTipForm::setToolTipInfo(QString strTip)
{ui-label-setText(strTip);
}void ToolTipForm::adjustWidSize(int w, int h)
{resize(w,h);ui-frame-resize(w,h);ui-label-resize(w,h);
}void ToolTipForm::onChangedSize(int count)
{if (count 6 count 8) {adjustWidSize(200,200);}else if (count 8 count 12) {adjustWidSize(200,300);}else if (count 12 count 16) {adjustWidSize(200,400);}else {adjustWidSize(200,500);}
}
以上只是窗口根据显示内容多少做出调整的一种思路仅供参考。