如何在visual studio 2010中创建空Qt项目(How to create empty Qt project in visual studio 2010)
使用visual studio C ++ 2010 Ult。 我已经编译并安装了Qt库,并且Visual Studio插件安装到VC ++中,因此我基本上能够使用来自VS加载项的Qt模板构建Qt应用程序。 我也能够包含Qt标题,所有的作品都很好......
使用VSC ++命令promt完成安装,然后使用configure和nmake完全构建。
QTDIR和PATH已正确设置。 Qt库安装到:(QTDIR)C:\ Users \ Admin \ Documents \ Libraries \ Qt(PATH)C:\ Users \ Admin \ Documents \ Libraries \ Qt \ bin
BIG BUT:当装箱新的空(或其他非Qt模板)项目时,我不能包含任何Qt标题,所以我的问题是如何启用它。
我想设置这个,所以我可以在以后的所有项目中简单地写:
#include <Qapplication> #include <Qlabel> //etc...
非常感谢。
Using visual studio C++ 2010 Ult. I have compiled and instaled Qt libraries and visual studio add-in is installed into VC++ so I'm basicaly able to build Qt applications using Qt templates ofered from VS add-in. I'm also able to include Qt headers and all works just fine...
installation has been done using VSC++ command promt, full build using configure and nmake then.
QTDIR and PATH are properly seted up. Qt libs are installed into: (QTDIR) C:\Users\Admin\Documents\Libraries\Qt (PATH) C:\Users\Admin\Documents\Libraries\Qt\bin
BIG BUT: when crating new empty(or other non Qt template) project I can't include any Qt header so my question is how to enable this.
I want to set this so I can in all my future projects simply write:
#include <Qapplication> #include <Qlabel> //etc...
thanks alot.
原文:https://stackoverflow.com/questions/8258131
最满意答案
需要在内存中过度分配data.table,以便通过引用工作来添加列。 加载后并非如此:
load("ttt") length(a) #[1] 1 truelength(a) #[1] 0 b <- data.table(x=1:2) length(b) #[1] 1 truelength(b) #[1] 100
来自
help(truelength)
:但是对于从磁盘加载的表,在R 2.14.0中truelength为0,在R <= 2.13.2中随机为0; 也就是说,在这两种情 data.table检测此状态,并在下一列添加或删除发生时过度分配已加载的data.table。
但似乎你将一个(新加载的)data.table传递给一个函数,然后在函数内部通过引用添加过度分配,但是在全局环境中没有到达符号(只有函数内部的本地符号) )。 如果您直接在全局环境中执行此操作,或者未将data.table作为函数参数传递,则它可以正常工作。
如果data.table已经过度分配(通常就是这种情况,除了从磁盘上新加载的那个),那么有一些备用插槽可以通过引用添加到列中而没有浅拷贝(以实现过度分配) )需要通过以下方式完成
:=
函数内部。这可能值得一个错误报告(但我还没有检查是否已有)。
R version 3.0.1 (2013-05-16) Platform: x86_64-apple-darwin10.8.0 (64-bit) locale: [1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] microbenchmark_1.3-0 data.table_1.8.8 loaded via a namespace (and not attached): [1] tools_3.0.1
A data.table needs to be over-allocated in memory for adding columns by reference to work. After loading it that's not the case:
load("ttt") length(a) #[1] 1 truelength(a) #[1] 0 b <- data.table(x=1:2) length(b) #[1] 1 truelength(b) #[1] 100
From
help(truelength)
:For tables loaded from disk however, truelength is 0 in R 2.14.0 and random in R <= 2.13.2; i.e., in both cases perhaps unexpected. data.table detects this state and over-allocates the loaded data.table when the next column addition or deletion occurs.
But it seems like if you pass a (freshly loaded) data.table to a function and then add by reference inside the function over-allocation happens but doesn't reach the symbol up in the global environment (only the local symbol inside the function). If you do it in the global environment directly or don't pass the data.table as function parameter, it works.
If the data.table is over-allocated already (as is normally the case, other than when freshly loaded from disk), then there are spare slots for the column to be added into by reference and no shallow copy (to achieve over-allocation) needs to be done by
:=
inside the function.This might be worth a bug report (but I haven't checked if there is already one).
R version 3.0.1 (2013-05-16) Platform: x86_64-apple-darwin10.8.0 (64-bit) locale: [1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] microbenchmark_1.3-0 data.table_1.8.8 loaded via a namespace (and not attached): [1] tools_3.0.1
相关问答
更多-
要回答你的编辑,只需运行一个基准: a = data.table(id=letters[1:2], var=1:2) b = copy(a) c = copy(b) # let's also just try modifying same value in place # to see how well changing existing values does microbenchmark(a <- rbind(a, data.table(id="c", var=3)), ...
-
在这两种情况下,数据表的长度为2,truelength为100: > length(dt); truelength(dt) [1] 2 [1] 100 > length(dt1); truelength(dt1) [1] 2 [1] 100 但是,在dt的情况下, colNames为300,因此2 + 300超过了truelength,但在dt1的情况下, colNames为81,因此2 + 81不会。 您可以提前分配更大的真实长度,例如 alloc.col(dt, 1000) 或者您可以设置默认值,以 ...
-
是的,它在R中使用<- (或=或-> )进行子分配,从而制作整个对象的副本。 您可以使用tracemem(DT)和.Internal(inspect(DT))来跟踪,如下所示。 data.table特性:=和set()通过引用分配给它们传递的任何对象。 因此,如果该对象先前被复制(通过子分配<-或显式copy(DT) ),则该副本将通过引用进行修改。 DT <- data.table(a = c(1, 2), b = c(11, 12)) newDT <- DT .Internal(inspect(D ...
-
感谢@DaisyLee指出这个问题。 看来你设法挖掘出一个相当模糊和非常古老的测试,这个测试在你的代码上错误地发生了错误。 我提出了一个关于这个问题的问题并提出了一个解决方案 您的代码现在应该在data.table版本1.9.8+上运行。 一旦你更新了,你应该能够运行你最初尝试过的代码片段而不会错误,而不需要使用as.data.table或setDT 。 如果你有兴趣, 这里是修复的代码。 Thanks @DaisyLee for pointing out this issue. It seems you ...
-
这可以通过以下两个步骤或单步执行: 给定的表是: dt<- data.table(mtcars)[, list(dt.mtcars = list(.SD)), by = gear] 步骤1 - 让我们在dt每一行中添加列hp向量的列表 dt[, hp_vector := .(list(dt.mtcars[[1]][, hp])), by = list(gear)] 第2步 - 现在计算hp的最大值 dt[, max_hp := max(hp_vector[[1]]), by = list(gear)] ...
-
这两种范例正在取代整个对象,正如你所指出的那样,或者是写出“替代”功能,比如 `updt<-` <- function(x, ..., value) { ## x is the object to be manipulated, value the object to be assigned x$lbl <- paste0(x$lbl, value) x } 同 > d <- data.frame(x=1:5, lbl=letters[1:5]) > d x lbl 1 1 ...
-
需要在内存中过度分配data.table,以便通过引用工作来添加列。 加载后并非如此: load("ttt") length(a) #[1] 1 truelength(a) #[1] 0 b <- data.table(x=1:2) length(b) #[1] 1 truelength(b) #[1] 100 来自help(truelength) : 但是对于从磁盘加载的表,在R 2.14.0中truelength为0,在R <= 2.13.2中随机为0; 也就是说,在这两种情 data.table检 ...
-
渴望发表评论,以便发布答案。 与您的案件有关的一般性评论。 您可以通过使用:::运算符调用未导出的data.table函数来显式调用[.data.table 。 data.table:::`[.data.table`(x, i) 使用:::不是最佳实践,因为它使您负责包作者决定不直接向用户公开的函数。 您应该记住这一点,但是R CMD check仍然不会引发错误或警告。 根据Writing R Extensions : 使用foo:::f而不是foo::f可以访问未导出的对象。 通常不建议这样做,因为包装 ...
-
这是一个使用.EACHI来实现你想要做的事情的例子: ## Create a data.table that indicates the pairs of keys to columns New <- data.table( Species = c("virginica", "setosa", "versicolor"), FunCol = c("Petal.Length", "Petal.Width", "Sepal.Length")) ## Set the key of your origi ...
-
检查微基准测试结果失败,data.table通过引用更改(Check of microbenchmark results fails with data.table changed by reference)[2022-11-29]
最简单的方法是使用copy() : microbenchmark( f1 = copy(dt)[, y := mean(x)], f2 = copy(dt)[, y := median(x)], check = my_check, times=1L ) # Error: Input expressions are not equivalent. 将copy(dt)添加到混合中可以了解复制所花费的时间(如果需要,可以总是从f1和f2的运行时中减去它)。 microbenchmark( ...