SWT StyledText是否有高度限制?(Does SWT StyledText have a height limit?)
我正在尝试创建一个包含ScrolledComposite中显示的StyledText框的应用程序。 我在StyledText框中显示大量行有困难(超过2,550似乎会导致问题)。
StyledText框本身不能有滚动条,但必须可以通过ScrolledComposite滚动。 由于StyledText下方和上方还有其他需要滚动的项目,我不想要多个滚动条。
因此,对于大量数据,我有一个非常大(如高度)的StyledText框似乎在一定高度后停止。
问题是StyledText应该和它的内容一样高,而不是。 下面的差距的原因是包含复合材料正在调整StyledText报告的高度,但实际上它不是它的高度。
这是一段简化的示例代码来说明我的问题:
import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class ExpandBox2 { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Example"); shell.setLayout(new FillLayout()); ScrolledComposite scrolledComposite = new ScrolledComposite(shell, SWT.V_SCROLL); scrolledComposite.setLayout(new FillLayout(SWT.VERTICAL)); Composite mainComp = new Composite(scrolledComposite, SWT.NONE); mainComp.setLayout(new FillLayout(SWT.VERTICAL)); StyledText styledText = new StyledText(mainComp, SWT.NONE); styledText.getContent().setText(bigString()); mainComp.setSize(mainComp.computeSize(SWT.DEFAULT, SWT.DEFAULT)); scrolledComposite.setContent(mainComp); scrolledComposite.setMinSize(mainComp.computeSize(SWT.DEFAULT, SWT.DEFAULT)); scrolledComposite.setExpandHorizontal(true); scrolledComposite.setExpandVertical(true); scrolledComposite.getVerticalBar().setIncrement(10); shell.setSize(400, 350); shell.open(); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) { display.sleep (); } } display.dispose(); } private static String bigString() { String big = ""; for(int i=0;i<10000;i++) { big = big + "hello\r\n"; } return big; } }
更新:有趣的是,SWT Label和SWT Text会出现此问题
I am trying to create an application that contains a StyledText box displayed within a ScrolledComposite. I am having difficulties displaying a large number of lines in my StyledText box (over 2,550 seems to cause issues).
The StyledText box must not itself have a scroll bar but must be scrollable via the ScrolledComposite. As there are other items below and above the StyledText that need to be scrollable to and I do not want multiple scroll bars.
Hence with large amounts of data I have a very large (as in height) StyledText box that seems to stop after a certain height.
The issue is that the StyledText should be as tall is its contents and it is not. The reason for the gap underneath is that the containing composite is resizing what StyledText reports to be its height but this is not in fact its height.
Here is a piece of simplified example code to illustrate my issue:
import org.eclipse.swt.SWT; import org.eclipse.swt.custom.ScrolledComposite; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class ExpandBox2 { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Example"); shell.setLayout(new FillLayout()); ScrolledComposite scrolledComposite = new ScrolledComposite(shell, SWT.V_SCROLL); scrolledComposite.setLayout(new FillLayout(SWT.VERTICAL)); Composite mainComp = new Composite(scrolledComposite, SWT.NONE); mainComp.setLayout(new FillLayout(SWT.VERTICAL)); StyledText styledText = new StyledText(mainComp, SWT.NONE); styledText.getContent().setText(bigString()); mainComp.setSize(mainComp.computeSize(SWT.DEFAULT, SWT.DEFAULT)); scrolledComposite.setContent(mainComp); scrolledComposite.setMinSize(mainComp.computeSize(SWT.DEFAULT, SWT.DEFAULT)); scrolledComposite.setExpandHorizontal(true); scrolledComposite.setExpandVertical(true); scrolledComposite.getVerticalBar().setIncrement(10); shell.setSize(400, 350); shell.open(); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) { display.sleep (); } } display.dispose(); } private static String bigString() { String big = ""; for(int i=0;i<10000;i++) { big = big + "hello\r\n"; } return big; } }
Update: Interestingly this problem occurs with SWT Label and SWT Text
原文:https://stackoverflow.com/questions/4510579
最满意答案
似乎QASM是重命名的过程,因此很多链接都被破坏了。 您可以在此github位置找到Open Quantum汇编语言规范:
https://github.com/IBM/qiskit-openqasm/tree/master/
PDF中的日期是2017年1月。
It seems that QASM is the process of being renamed, so many of the links are broken. You can find the Open Quantum Assembly Language spec at this github location:
https://github.com/IBM/qiskit-openqasm/tree/master/
The date in the PDF is January 2017.
相关问答
更多-
计算&&和||(Computing && and ||)[2023-02-01]
我的问题是:如果x.precomputedValue为true ,是否会计算functionReturningBoolean(x) ? 编号&&和|| 在Scala中短路。 你可以从文档中看出: 此方法使用“短路”评估,其行为就像声明为def ||(x: => Boolean): Boolean 。 如果计算结果为true ,则返回true而不评估b 。 更一般地说:只要编译器在“OR”语句中看到值为true ,它是否会查看语句中的第二个条件? 类似地,在一个“AND”语句中,例如a && b ,如果a是假 ... -
数值模拟在Python 3.2和3.3中给出了不同的结果(Numerical simulation giving different results in Python 3.2 vs 3.3)[2023-12-05]
你最后的要点很可能是原因。 在python3.3中 ,默认情况下启用了哈希随机化来解决安全问题。 基本上,这个想法是,你现在永远不知道你的字符串将如何散列(这决定了它们在字典中的顺序)。 这里有一个演示: d = {"a": 1, "b": 2, "c": 3} print(d) 在我的机器上,使用python3.4,这导致了3种不同的排序结果: $ python3.4 test.py {'a': 1, 'c': 3, 'b': 2} $ python3.4 test.py {'c': 3, 'b': 2 ... -
如果您只想在数字0,1,...,9上获得离散的均匀分布,那么只需使用样本 sample(0:9, k, replace = TRUE) 使用你现在拥有的代码,你实际得到的概率为0.05,每个得到0或10,概率为.10,得到1-9。 If all you want to do is get a discrete uniform distribution on the numbers 0, 1, ..., 9 then just use sample sample(0:9, k, replace = TRUE ...
-
它可能不会帮助整体速度(正如@Ander在他的回答中提到的那样),但是您可以做出的一点小改进就是直接在GPU上构建随机数字,如下所示: rand(1, 10000, 'gpuArray') 一般来说,GPU上的随机数生成要比CPU上的快得多。 你可以进一步使用gpuArray版本,它将JIT编译成本机GPU代码。 在我的GPU(Tesla K20c)上,这使GPU的版本比CPU版本快10倍。 以下是完整的脚本: %% CPU version tic Array=zeros(1,1000); for j=1 ...
-
我在你的代码中发现了一些问题: compute_dE方法返回错误的能量,因为因子2不应该存在。 伊辛系统的汉密尔顿主义是 在你有效使用的同时 compute_energy方法返回错误的能量。 该方法应仅迭代每个旋转对一次。 像这样的东西应该做的伎俩: for (unsigned int i = 0; i < max; i++) { for (unsigned int j = i + 1; j < max; j++) { energy_sum += other.compute_point_energy(i, ...
-
没有用于管理GUI运行状态的API。 原因是,您可以在Cmdenv中运行模拟而无需重新编译代码,并且在Cmdenv中暂停模拟是不可能/没有意义的。 但是你可以做一个技巧,因为模拟是可重复的: 添加一些代码,在特定条件发生时打印出事件编号。 运行模拟并记下模拟运行时打印出的事件编号。 现在再次开始模拟(使用相同的参数),但使用“Run until ... / Event number”并指定GUI应停止的事件编号。 There is no API for managing the GUI's run stat ...
-
可以用简单的代码示例解释量子位和位之间的区别吗?(Can the difference between qubit and bit be explained with a simple code example?)[2022-06-06]
这里有一些经典的代码翻转硬币并计算你得到多少头: def coin_count(): bit = False counter = 0 for _ in range(500): bit ^= random() < 0.5 # False → 50% False, 50% True # True → 50% False, 50% True if bit: counte ... -
只是解决方案 这是lsqnonlin一个非常标准的lsqnonlin ,你只需要正确地格式化它。 这意味着这样的事情: %First, define a function whose inputs are a single vector, and whose %outputs can be minimized funToMinimize = @(abc) myfunction(Xdata,abc(1), abc(2), abc(3)) - Ydata; %Define an initial guess o ...
-
似乎QASM是重命名的过程,因此很多链接都被破坏了。 您可以在此github位置找到Open Quantum汇编语言规范: https://github.com/IBM/qiskit-openqasm/tree/master/ PDF中的日期是2017年1月。 It seems that QASM is the process of being renamed, so many of the links are broken. You can find the Open Quantum Assembly L ...
-
什么是鸽子计算?(What is pigeon computing?)[2022-06-01]
这可能是指PigeonRank ,这是谷歌的愚人节之一 This is probably referring to PigeonRank, which is one of Google's April Fools