小编Ton*_*ton的帖子

QML 布局:如何为行或列布局中的项目赋予权重?

我试图通过为每个项目指定一种权重来找出按比例布局项目的方法。例如,Android 的布局方式

我试图实现它的方式是这样的:

import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3

GridLayout {
    columns: 4
    width: 640
    height: 480

    Rectangle {
        color: "red"
        Layout.fillHeight: true
        Layout.fillWidth: true
        Layout.columnSpan: 1
    }
    Rectangle {
        color: "#80000000"
        Layout.fillHeight: true
        Layout.fillWidth: true
        Layout.columnSpan: 2
    }
    Rectangle {
        color: "blue"
        Layout.fillHeight: true
        Layout.fillWidth: true
        Layout.columnSpan: 1
    }
}
Run Code Online (Sandbox Code Playgroud)

我希望中间矩形的宽度是其他两个矩形的总和,但它们的宽度都是相等的。

在 Layout 附加属性上使用关系绑定似乎总是会导致奇怪的绑定循环。我知道我可以只使用 Row 代替关系绑定,但如果可能的话,我更喜欢使用 Layouts。

编辑

这似乎按照我想要的方式工作,但我不知道为什么会这样。它的行为就好像该preferredWidth值是项目的重量。

import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3

RowLayout {
    width: 640 …
Run Code Online (Sandbox Code Playgroud)

qt qml qgridlayout

7
推荐指数
1
解决办法
1933
查看次数

WinAPI:如何确定网络何时识别?

通过以太网连接某些设备时,我可以看到"网络连接"面板中的适配器状态更改为"识别网络".我想使用c ++ Windows API查询此状态.

ipconfig /all在我的项目中实现了一些动态列表.当网络接口上的网络正在识别时,我将要显示"识别网络".

我知道INetwork接口,但它只能通过COM访问.还有另外一种方法吗?也许来自有关网络接口本身的信息?

c++ windows networking winapi

3
推荐指数
1
解决办法
280
查看次数

什么是 ID3D12GraphicsCommandList::DiscardResource?

使用DiscardResource时我到底应该期望发生什么?

丢弃和销毁/删除资源有什么区别?

什么时候是丢弃资源的好时机/用例?

不幸的是,除了“丢弃资源”之外,微软似乎没有对此说太多。

directx direct3d directx-12 direct3d12

2
推荐指数
1
解决办法
1095
查看次数

标签 统计

c++ ×1

direct3d ×1

direct3d12 ×1

directx ×1

directx-12 ×1

networking ×1

qgridlayout ×1

qml ×1

qt ×1

winapi ×1

windows ×1