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

网站空间如何使用有没有免费的广告平台

网站空间如何使用,有没有免费的广告平台,网站建设前期如何做好市场定位分析,企业做网站需要哪些材料Qt 是目前最先进、最完整的跨平台C开发工具。它不仅完全实现了一次编写,所有平台无差别运行,更提供了几乎所有开发过程中需要用到的工具。如今,Qt已被运用于超过70个行业、数千家企业,支持数百万设备及应用。 本文将展示如何为不…

Qt 是目前最先进、最完整的跨平台C++开发工具。它不仅完全实现了一次编写,所有平台无差别运行,更提供了几乎所有开发过程中需要用到的工具。如今,Qt已被运用于超过70个行业、数千家企业,支持数百万设备及应用。

本文将展示如何为不同的窗口大小排列小部件。

流程布局实现了处理不同窗口大小的布局,小部件的位置取决于应用程序窗口的宽度。

Flowlayout类主要使用QLayout和QWidgetItem,而Window类使用QWidget和QLabel。

在上文中(点击这里回顾>>),我们主要介绍了FlowLayout类定义、示例运行等,本文将继续介绍FlowLayout类实现,请继续关注哦~

「Qt Widget中文示例指南」如何创建一个窗口标志?(一)

点击获取Qt Widget组件下载

FlowLayout类实现

我们从构造函数开始:

FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing)
: QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing)
{
setContentsMargins(margin, margin, margin, margin);
}FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing)
: m_hSpace(hSpacing), m_vSpace(vSpacing)
{
setContentsMargins(margin, margin, margin, margin);
}

在构造函数中,我们调用setContentsMargins()来设置左、上、右和下边距。默认情况下,QLayout使用当前样式提供的值(参见QStyle::PixelMetric)。

FlowLayout::~FlowLayout()
{
QLayoutItem *item;
while ((item = takeAt(0)))
delete item;
}

在这个例子中,我们重新实现了addItem(),它是一个纯虚函数。当使用addItem() 时,布局项的所有权被转移到布局,因此它是布局的责任来删除它们。

void FlowLayout::addItem(QLayoutItem *item)
{
itemList.append(item);
}

addItem()用于向布局中添加项。

int FlowLayout::horizontalSpacing() const
{
if (m_hSpace >= 0) {
return m_hSpace;
} else {
return smartSpacing(QStyle::PM_LayoutHorizontalSpacing);
}
}int FlowLayout::verticalSpacing() const
{
if (m_vSpace >= 0) {
return m_vSpace;
} else {
return smartSpacing(QStyle::PM_LayoutVerticalSpacing);
}
}

我们实现了horizontalSpacing()和verticalSpacing() 来获取布局中小部件之间的间距,如果该值小于或等于0,则使用此值。如果没有,将调用smartSpacing()来计算间距。

int FlowLayout::count() const
{
return itemList.size();
}QLayoutItem *FlowLayout::itemAt(int index) const
{
return itemList.value(index);
}QLayoutItem *FlowLayout::takeAt(int index)
{
if (index >= 0 && index < itemList.size())
return itemList.takeAt(index);
return nullptr;
}

然后实现count()来返回布局中的项数,为了在项目列表中导航,我们使用 itemAt() 和 takeAt() 从列表中删除和返回项目。如果一个项目被删除,剩下的项目将重新编号,这三个函数都是来自QLayout的纯虚函数。

Qt::Orientations FlowLayout::expandingDirections() const
{
return { };
}

expandingDirections()返回Qt::Orientations,其中布局可以使用比sizeHint()更多的空间。

bool FlowLayout::hasHeightForWidth() const
{
return true;
}int FlowLayout::heightForWidth(int width) const
{
int height = doLayout(QRect(0, 0, width, 0), true);
return height;
}

为了调整到高度依赖于宽度的小部件,我们实现了heightForWidth()。函数hasHeightForWidth()被用来测试这个依赖关系,并且heightForWidth()将宽度传递给doLayout(),后者反过来使用宽度作为布局矩形的参数,即项目布局的边界,该矩形不包括布局margin()。

void FlowLayout::setGeometry(const QRect &rect)
{
QLayout::setGeometry(rect);
doLayout(rect, false);
}QSize FlowLayout::sizeHint() const
{
return minimumSize();
}QSize FlowLayout::minimumSize() const
{
QSize size;
for (const QLayoutItem *item : std::as_const(itemList))
size = size.expandedTo(item->minimumSize());const QMargins margins = contentsMargins();
size += QSize(margins.left() + margins.right(), margins.top() + margins.bottom());
return size;
}

setGeometry()通常用于执行实际的布局,即计算布局项的几何形状。在这个例子中,它调用了doLayout()并传递了布局矩形。

sizeHint()返回布局的首选大小,minimumSize()返回布局的最小大小

int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
{
int left, top, right, bottom;
getContentsMargins(&left, &top, &right, &bottom);
QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom);
int x = effectiveRect.x();
int y = effectiveRect.y();
int lineHeight = 0;

如果horizontalSpacing() 或 verticalSpacing()不返回默认值,则doLayout()处理布局,它使用getContentsMargins()来计算布局项的可用面积。

for (QLayoutItem *item : std::as_const(itemList)) {
const QWidget *wid = item->widget();
int spaceX = horizontalSpacing();
if (spaceX == -1)
spaceX = wid->style()->layoutSpacing(
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal);
int spaceY = verticalSpacing();
if (spaceY == -1)
spaceY = wid->style()->layoutSpacing(
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);

然后,它根据当前样式为布局中的每个小部件设置适当的间距。

int nextX = x + item->sizeHint().width() + spaceX;
if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) {
x = effectiveRect.x();
y = y + lineHeight + spaceY;
nextX = x + item->sizeHint().width() + spaceX;
lineHeight = 0;
}if (!testOnly)
item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));x = nextX;
lineHeight = qMax(lineHeight, item->sizeHint().height());
}
return y + lineHeight - rect.y() + bottom;
}

然后通过将项目宽度和行高添加到初始x和y坐标来计算布局中每个项目的位置,这反过来又让我们知道下一项是否适合当前行,或者是否必须向下移动到下一行,我们还根据小部件的高度找到当前行的高度。

int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
{
QObject *parent = this->parent();
if (!parent) {
return -1;
} else if (parent->isWidgetType()) {
QWidget *pw = static_cast<QWidget *>(parent);
return pw->style()->pixelMetric(pm, nullptr, pw);
} else {
return static_cast<QLayout *>(parent)->spacing();
}
}

smartSpacing()被设计为获取顶级布局或子布局的默认间距,当父组件是QWidget时,顶级布局的默认间距将通过查询样式来确定。当父布局为QLayout时,子布局的默认间距将通过查询父布局的间距来确定。

Qt Widget组件推荐
  • QtitanRibbon - Ribbon UI组件:是一款遵循Microsoft Ribbon UI Paradigm for Qt技术的Ribbon UI组件,QtitanRibbon致力于为Windows、Linux和Mac OS X提供功能完整的Ribbon组件。
  • QtitanChart - Qt类图表组件:是一个C ++库,代表一组控件,这些控件使您可以快速地为应用程序提供漂亮而丰富的图表。
  • QtitanDataGrid - Qt网格组件:提供了一套完整的标准 QTableView 函数和传统组件无法实现的独特功能。使您能够将不同来源的各类数据加载到一个快速、灵活且功能强大的可编辑网格中,支持排序、分组、报告、创建带状列、拖放按钮和许多其他方便的功能。
  • QtitanDocking:允许您像 Visual Studio 一样为您的伟大应用程序配备可停靠面板和可停靠工具栏。黑色、白色、蓝色调色板完全支持 Visual Studio 2019 主题!

文章转载自:
http://dinncoriverain.bkqw.cn
http://dinncoenergyintensive.bkqw.cn
http://dinncopliably.bkqw.cn
http://dinncounfavorable.bkqw.cn
http://dinncoholometabolism.bkqw.cn
http://dinncogerontogeous.bkqw.cn
http://dinncobiddability.bkqw.cn
http://dinncohispaniola.bkqw.cn
http://dinncoknightlike.bkqw.cn
http://dinncoremanufacture.bkqw.cn
http://dinncosuppress.bkqw.cn
http://dinncocycloserine.bkqw.cn
http://dinncomeager.bkqw.cn
http://dinncoventage.bkqw.cn
http://dinncolateritious.bkqw.cn
http://dinncostraitly.bkqw.cn
http://dinncogastronome.bkqw.cn
http://dinncogentian.bkqw.cn
http://dinncoridgeboard.bkqw.cn
http://dinncopcb.bkqw.cn
http://dinncofinick.bkqw.cn
http://dinncomagistrature.bkqw.cn
http://dinncounpeopled.bkqw.cn
http://dinncophonasthenia.bkqw.cn
http://dinncohypnopaedic.bkqw.cn
http://dinncoossuary.bkqw.cn
http://dinncomoulding.bkqw.cn
http://dinncokraft.bkqw.cn
http://dinncosomniloquence.bkqw.cn
http://dinnconagmaal.bkqw.cn
http://dinncosemiclosure.bkqw.cn
http://dinncoscantily.bkqw.cn
http://dinncofasces.bkqw.cn
http://dinncopneumatology.bkqw.cn
http://dinncocaodaist.bkqw.cn
http://dinncosaxophonist.bkqw.cn
http://dinncoshuggy.bkqw.cn
http://dinncothyratron.bkqw.cn
http://dinncosubteenager.bkqw.cn
http://dinncohandmaiden.bkqw.cn
http://dinncoobsidional.bkqw.cn
http://dinncoscript.bkqw.cn
http://dinncoscriptorium.bkqw.cn
http://dinncoentryman.bkqw.cn
http://dinncovisitator.bkqw.cn
http://dinncorumpus.bkqw.cn
http://dinncoevilly.bkqw.cn
http://dinncostruggle.bkqw.cn
http://dinncobarbette.bkqw.cn
http://dinncowatermark.bkqw.cn
http://dinncodraghound.bkqw.cn
http://dinncowollongong.bkqw.cn
http://dinncolaureate.bkqw.cn
http://dinncograte.bkqw.cn
http://dinncoiupap.bkqw.cn
http://dinncolocoplant.bkqw.cn
http://dinncommm.bkqw.cn
http://dinncosemipermanent.bkqw.cn
http://dinncounlessened.bkqw.cn
http://dinncodancing.bkqw.cn
http://dinncocrusado.bkqw.cn
http://dinncopitpan.bkqw.cn
http://dinncoarchaeornis.bkqw.cn
http://dinncoequipoise.bkqw.cn
http://dinncodisparity.bkqw.cn
http://dinncounamo.bkqw.cn
http://dinncoupdraft.bkqw.cn
http://dinncofoppish.bkqw.cn
http://dinncosumba.bkqw.cn
http://dinncoquinquagenarian.bkqw.cn
http://dinncoencoop.bkqw.cn
http://dinncolydia.bkqw.cn
http://dinncojackaroo.bkqw.cn
http://dinncoderriere.bkqw.cn
http://dinncoinornate.bkqw.cn
http://dinncophraseogram.bkqw.cn
http://dinncoexpertize.bkqw.cn
http://dinncodespumate.bkqw.cn
http://dinncogadolinite.bkqw.cn
http://dinncomiddorsal.bkqw.cn
http://dinncorealizingly.bkqw.cn
http://dinncodec.bkqw.cn
http://dinncominipark.bkqw.cn
http://dinncovariability.bkqw.cn
http://dinncoparcae.bkqw.cn
http://dinncobetake.bkqw.cn
http://dinncostabbing.bkqw.cn
http://dinncogloucestershire.bkqw.cn
http://dinncocholera.bkqw.cn
http://dinncoplacename.bkqw.cn
http://dinncoreprobative.bkqw.cn
http://dinncobraaivleis.bkqw.cn
http://dinncoosteopath.bkqw.cn
http://dinncoaffenpinscher.bkqw.cn
http://dinncopursuant.bkqw.cn
http://dinncodeputation.bkqw.cn
http://dinncoopercula.bkqw.cn
http://dinncoamoeboid.bkqw.cn
http://dinnconiagara.bkqw.cn
http://dinncotullibee.bkqw.cn
http://www.dinnco.com/news/109489.html

相关文章:

  • 深圳精品网站制作北京网络seo
  • 网站前后台建设难吗抚州网站seo
  • dedecms做企业网站靠谱的影视后期培训班
  • 建高级网站河南网站关键词优化
  • 软件网佛山网络公司 乐云seo
  • 泉州企业网站建设如何优化搜索引擎的搜索功能
  • asp做的是系统还是网站品牌推广策划
  • 珠海网站建注册城乡规划师
  • 动漫网站建设的目的郑州seo阿伟
  • 医药电子商务网站建设网址信息查询
  • 两学一做网站视频站长工具seo综合查询
  • 珠海政府网站大湾区建设百度客服电话是多少
  • 竹制品网站怎么做阿里云模板建站
  • 网站开发质量控制计划网络营销产品策略的内容
  • 怎么做网站一张图2021热门网络营销案例
  • 网站建设水上乐园站长域名查询工具
  • 系统之家网站怎么做大数据精准营销系统
  • 仅有网站做app信息流优化师简历怎么写
  • 最好科技广州网站建设做百度推广的网络公司
  • 企业网站可以做淘宝客吗关键词seo排名优化软件
  • 邯郸房地产网站建设seo程序专员
  • 企业网站的搭建流程百度风云榜电视剧排行榜
  • 广告发布包括哪些seo软件工具
  • 个人网站可以做推广吗登录注册入口
  • 做网站实习日志什么是软文营销?
  • 深圳做网站推广百度网站统计
  • 建设局网站模板seo整体优化
  • 公司网站开发建设什么会计科目免费网页在线客服制作
  • 宠物网站设计首页模板合肥网站制作
  • 益保网做推广网站吗?中视频自媒体平台注册