小编iam*_*mnp的帖子

改变数百个WinForms控件位置的性能

我有一个循环:

for (int i = 0; i < panel1->Controls->Count; ++i) {
    Control^ ctl = panel1->Controls[i];
    ctl->Location.Y = i*10;
}
Run Code Online (Sandbox Code Playgroud)

如果我在panel1中有200或300个控件可以吗?或者如果我添加这个会更好:

if (ctl->Location.Y != i*10) ctl->Location.Y = i*10;
Run Code Online (Sandbox Code Playgroud)

我只是不知道.NET的控件是否会重新绘制(需要时间)或者他们会自动检查是否需要重绘(仍然是相同的位置)

.net performance winforms

9
推荐指数
1
解决办法
132
查看次数

GoLang GraphQL 无法从 nil 文字中分辨出 nil 指针

在我的 GoLang GraphQL 查询中,我有以下方法(获取用户 ID 并返回配置文件数据):

    "userProfile": &graphql.Field{
        Type: UserProfileType,
        Args: graphql.FieldConfigArgument{
            "uid": &graphql.ArgumentConfig{
                Type:         graphql.Int,
            },
        },
        Resolve: func(p graphql.ResolveParams) (interface{}, error) {
            uid := p.Args["uid"].(int)
            u, err := db.GetUserProfile(p.Context.Value(handler.CtxId("currentUser")).(int), uid)
            return u, err
        },
    },
Run Code Online (Sandbox Code Playgroud)

当用户 id 无效时db.GetUserProfile返回 nil 指针u和 nil error err,但 GraphQL 响应如下:

{
"data": { "userProfile": null },
"errors": [
        {
            "message": "runtime error: invalid memory address or nil pointer dereference",
            "locations": []
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

虽然当我像这样修改 GraphQL 代码时(显式 nil …

go graphql

5
推荐指数
0
解决办法
319
查看次数

Qt 5将Qt5Core.dll放入一个文件夹中

现在我有我的app文件的结构:

-myApp.exe
-Qt5Core.dll
-Qt5Gui.dll
-Qt5Widgets.dll
-platforms
|-qwindows.dll
Run Code Online (Sandbox Code Playgroud)

是否可以将所有dll放入一个文件夹:

-myApp.exe
-libs
|-Qt5Core.dll
|-Qt5Gui.dll
|-Qt5Widgets.dll
|-platforms
||-qwindows.dll
Run Code Online (Sandbox Code Playgroud)

我知道我可以静态构建Qt并运行没有任何dll的应用程序,但我想保留它们,只需放入一个文件夹

c++ dll qt qt5 qtcore

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

c ++指针和索引更改位置

我在互联网上找到了这个代码,并想知道它是如何工作的?

int m[10]; //array with 10 elements
for (int i=0; i<10; ++i)
    m[i] = i; //simple initializing

int* a = &m[0]; //a - pointer at the first array's element

3[a] = 20; //???

for (int i=0; i<10; ++i)
    cout << m[i] << endl;//out
Run Code Online (Sandbox Code Playgroud)

你可以猜到输出是:

0
1
2
20
4
5
6
7
8
9
Run Code Online (Sandbox Code Playgroud)

c++ pointers

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

Swift关闭奇怪的行为

为什么这段代码编译(在Playground中):

func text (f: String -> Void) {
    f("text")
}

func foo(s: String) {
    countElements(s)
}

text() {
    s in
        foo(s)
}
Run Code Online (Sandbox Code Playgroud)

而这个不是:

func text (f: String -> Void) {
    f("text")
}

func foo(s: String) {
    countElements(s)
}

text() {
    s in
        countElements(s)
}
Run Code Online (Sandbox Code Playgroud)

有错误消息:

Cannot convert the expression's type '(($T3) -> ($T3) -> $T2) -> (($T3) -> $T2) -> $T2'       to type '_BuiltinIntegerLiteralConvertible'
Run Code Online (Sandbox Code Playgroud)

我可以说有返回类型的东西,有点Swift认为我想返回int但我只想打印它

xcode objective-c ios swift swift-playground

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

标签 统计

c++ ×2

.net ×1

dll ×1

go ×1

graphql ×1

ios ×1

objective-c ×1

performance ×1

pointers ×1

qt ×1

qt5 ×1

qtcore ×1

swift ×1

swift-playground ×1

winforms ×1

xcode ×1