Qt Creator是否像Intellij IDEA一样呈现智能代码完成?例如:
void main() {
QString simpleVariableName = "First string";
QString anotherVariableName = "Second string";
// If I type "variable" and press Ctrl + Space I would like to get
// all matching variables(simple and another) in popup list. In
// IDEA it works, but Qt Creator show nothing.
}
Run Code Online (Sandbox Code Playgroud)
我听到了大量的Clang Code Model插件,它已经安装在我的3.4.0版本中了.但这没有任何意义,我仍然有默认行为.
有没有办法让真正的智能代码完成?
我有两个程序:
第二个程序代码如下所示:
String[] arguments = {
"cmd", "/c",
"java", "-cp", classPath
lauchClass,
// Arguments for first program
}
ProcessBuilder pb = new ProcessBuilder(arguments);
pb.environment().putAll(System.getenv());
pb.directory(workDir);
pb.inheritIO();
Process process = pb.start();
process.waitFor();
Run Code Online (Sandbox Code Playgroud)
当第一个程序从第二个程序开始时,System.console()为空,它随NPE失败.
所以,问题是:有没有办法运行System.console()的另一个进程?
我有一个自定义QAbstractItemModel和自定义树视图。
是否可以合并QTreeView中的某些单元格?
它看起来像这样:
Num | Name | Qty | .... |
----|-----------|-----|------|
1 | Unit one | 5 | .... |
1.1 | Sub unit1 | 3 | .... |
1.2 | Very very big string |
1.3 | Sub unit2 | 2 | .... |
Run Code Online (Sandbox Code Playgroud)
同样,QTreeWidget :: setFirstColumnSpanned()也不是必须的。
我有一个包含一些数据的组合框.
public class Test extends Application {
public static final String[] items = "One Two Three".split(" ");
@Override
public void start(Stage primaryStage) throws Exception {
final ComboBox<String> box = new ComboBox<>(FXCollections.observableArrayList(items));
box.getSelectionModel().selectFirst();
primaryStage.setScene(new Scene(box));
primaryStage.show();
}
}
Run Code Online (Sandbox Code Playgroud)
如果我设置组合框禁用它会变灰但我需要将文本设置为黑色.谷歌说我需要将不透明度设置为1.0.
box.setDisable(true);
box.setStyle("-fx-opacity: 1.0;");
Run Code Online (Sandbox Code Playgroud)
没有任何反应.它也变灰了.
即使我将text-fill
属性设置为黑色,它也会变灰.
box.setDisable(true);
box.setStyle("-fx-opacity: 1.0; -fx-text-fill: black;");
Run Code Online (Sandbox Code Playgroud)
怎么了?如何更改已禁用组合框的文本颜色?
有没有办法序列化javafx.scene.image.Image?
我发现只有一种方法:创建自己的可序列化类,以像素格式(byte [] [])存储图像数据.我无法相信JavaFX没有用于图像序列化的内置机制.
这是我的SerializableImage类.
import javafx.scene.image.Image;
import javafx.scene.image.PixelReader;
import javafx.scene.image.PixelWriter;
import javafx.scene.image.WritableImage;
import java.io.Serializable;
public class SerializableImage implements Serializable {
private int width, height;
private int[][] data;
public SerializableImage() {}
public void setImage(Image image) {
width = ((int) image.getWidth());
height = ((int) image.getHeight());
data = new int[width][height];
PixelReader r = image.getPixelReader();
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
data[i][j] = r.getArgb(i, j);
}
} …
Run Code Online (Sandbox Code Playgroud) 我有以下情况:一个包含大文件的目录树(大约 5000 个文件,大小约为 4Gb)。我需要在这棵树中找到重复项。
我尝试使用 Java 内置的 CRC32 和 Adler32 类,但它非常慢(每个文件大约 3-4 分钟)。
代码是这样的:
1) Init map <path, checksum>
2) Create CheckSum instance (CRC32 or Adler32);
3) Read file per block (10-100 bytes);
4) In each iteration call update()
5) Result checksum passed in map <path, summ>
6) Find duplicates
Run Code Online (Sandbox Code Playgroud)
问题:有什么方法可以加快第 3-4 行校验和的收集速度吗?