我有一个Qt应用程序,我有一个textedit和一个标签.当用户按下按钮时,textedit文本应显示在标签上.对于标签我设置了一些属性,如启用了自动换行,水平和垂直,它是对齐的中心.以下是截图:
现在我必须自动调整标签中文本的大小,这样如果有人输入一个大字符串,那么它应该适合标签内部,这意味着文本的大小应该减少.如果文本字符串很小,那么大小应该自动增加以填满整个标签.目前,如果我输入大字符串,它看起来像是:
如您所见,在上图中,文本正在移出标签.它应该保留在标签内.
如何在应用程序中检测文本是否移出标签高度和宽度.那么如何减少文字大小.如果字符串很小,我希望大小自动增加,减少字符串很大,以填满整个标签.QT中是否提供任何课程或内容.任何帮助或示例请.谢谢.
编辑:使用下面的代码我可以减少文本的大小以适应标签宽度,但不能使文本多行.
QString string = ui->textEdit->toPlainText(); //Getting data from textEdit
ui->label->setAlignment(Qt::AlignCenter); //Aligning label text to center
QFont f("Arial",50); //Setting the default font size to 50
QFontMetrics fm(f);
ui->label->setFont(f); //Setting the font to the label
int width = fm.width(string); //Getting the width of the string
int size;
while(width >= 870) //870 is the max width of label
{
size = ui->label->font().pointSize()-1; //Reduce font size by 1
QFont newFont("Arial",size);
QFontMetrics nfm(newFont);
ui->label->setFont(newFont); //Set the new font with new size …Run Code Online (Sandbox Code Playgroud) 我在gtk应用程序中遇到上述警告。我知道这个问题已经讨论过了,但是我的问题是我什至没有使用此功能。
我要做的就是从文件中读取文本字符串,然后使用pango更改其字体类型和字体大小,然后将结果应用于gtk标签,这是代码:
FILE *fp;
long lSize;
char *buffer;
fp = fopen ( "/home/user/file.txt" , "rb" );
if( !fp ) perror("file.txt"),exit(1);
fseek( fp , 0L , SEEK_END);
lSize = ftell( fp );
rewind( fp );
buffer = calloc( 1, lSize+1 );
if( !buffer ) fclose(fp),fputs("memory alloc fails",stderr),exit(1);
if( 1!=fread( buffer , lSize, 1 , fp) )
fclose(fp),free(buffer),fputs("entire read fails",stderr),exit(1);
buffer[lSize+2]='\0';
PangoFontDescription *font = pango_font_description_new (); //NEW PANGO FONT
pango_font_description_set_family (font,"Arial Rounded MT Bold"); //FONT FAMILY
pango_font_description_set_size(font,60*PANGO_SCALE); //FONT SIZE
gtk_widget_override_font(GTK_WIDGET(label), font); //APPLYING …Run Code Online (Sandbox Code Playgroud) 我已经设置了 Fluentd 记录器,并且可以使用 Fluentdtail input插件来监视文件。所有数据由 fluidd 接收,随后发布到elasticsearch集群。以下是 fluidd 的配置文件:
<source>
@type tail
path /home/user/Documents/log_data.json
format json
tag myfile
</source>
<match *myfile*>
@type elasticsearch
hosts 192.168.48.118:9200
user <username>
password <password>
index_name fluentd
type_name fluentd
</match>
Run Code Online (Sandbox Code Playgroud)
如您所见,我正在log_data.json使用tail. 我在同一目录中也有一个文件log_user.json,我也想监视它并将其日志发布到elasticsearch. 为此,我想用不同的标签创建另一个<source>& <match>,但它开始显示错误。
如何监视多个文件并将fluentd它们发布到elasticsearch. 我看到当我们启动时fluentd它的工作人员就启动了。是否可以启动多个工作程序,以便每个工作程序都监视不同的文件,或者使用任何其他方式来执行此操作。谁能给我指出一些好的链接/教程。
谢谢。
我的kubernetes集群工作正常。它有5个工作节点。我正在使用以下命令来获取Pod的状态。
kubectl get pod -o wide --namespace=machines
Run Code Online (Sandbox Code Playgroud)
显示以下结果
NAME READY STATUS RESTARTS AGE IP NODE
deployment-26hfn 0/4 ContainerCreating 0 5m <none> machine003
deployment-782mk 0/4 Pending 0 5m <none> machine001
deployment-7kcc7 0/4 Pending 0 5m <none> machine002
deployment-8fzqs 0/4 ContainerCreating 0 5m <none> machine004
deployment-zfzts 0/4 ContainerCreating 0 5m <none> machine005
Run Code Online (Sandbox Code Playgroud)
如您所见,以上结果并非按从machine001到的顺序排列machine 005。是否可以打印如下输出:
NAME READY STATUS RESTARTS AGE IP NODE
deployment-26hfn 0/4 Pending 0 5m <none> machine001
deployment-782mk 0/4 Pending 0 5m <none> machine002
deployment-7kcc7 …Run Code Online (Sandbox Code Playgroud) 是否可以从 kubernetes 中的 pod 内的主机上运行命令。
例如,我有一个运行 python 图像的 pod,它会计算 os 的大小。但它使用的命令在 Pod 内部运行,而不是在主机中运行。是否可以从 pod 在主机上运行该命令。
我有 kubernetes 集群运行在Ubuntu 16.04. 当我运行时,它nslookup kubernetes.default显示master如下:
Server: 192.168.88.21
Address: 192.168.88.21#53
** server can't find kubernetes.default: NXDOMAIN
Run Code Online (Sandbox Code Playgroud)
下面是内容/etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.88.21
nameserver 127.0.1.1
search VISDWK.local
Run Code Online (Sandbox Code Playgroud)
使用kubernetes版本
kubeadm version: &version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.1", GitCommit:"eec55b9ba98609a46fee712359c7b5b365bdd920", GitTreeState:"clean", BuildDate:"2018-12-13T10:36:44Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"linux/amd64"}
Run Code Online (Sandbox Code Playgroud)
使用 weave 进行联网并使用以下命令安装:
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')" …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 C# 将图像文件从本地系统上传到 azure blob 存储。下面是我正在使用的代码:
string storageConnectionString = "<connection_string>";
CloudStorageAccount storageacc = CloudStorageAccount.Parse(storageConnectionString);
CloudBlobClient blobClient = storageacc.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("myblob");
container.CreateIfNotExists();
CloudBlockBlob blockBlob = container.GetBlockBlobReference("images");
using (var filestream = System.IO.File.OpenRead(@"C:\\Users\\John\\Desktop\\11173.jpg"))
{
blockBlob.UploadFromStream(filestream);
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试创建具有myblob我可以看到已创建名称的容器。在其中我创建一个带有名称的 blob images,然后在其中上传图像文件。但我看不到其中的图像文件。上面的代码有什么问题。如何将图像文件上传到 Blob 存储中。请帮忙。谢谢
我已经设置了 kubernetes运行良好集群。我deployment使用type 创建daemonset,然后创建了几个Pod,并且效果很好。我进行了一些更改,因此删除了daemonset使用方法:
kubectl delete daemonset <name> --namespace=clustech
Run Code Online (Sandbox Code Playgroud)
在删除几个Pod的同时,很少有机器脱机,因此在它们上面运行的Pod继续显示unknown状态。我需要删除那些吊舱或完全删除之前daemonset无法完成的吊舱。我正在使用以下命令删除吊舱:
kubectl delete pod PODNAME --grace-period=0 --force
Run Code Online (Sandbox Code Playgroud)
但这显示以下错误:
warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
Error from server (NotFound): pods "deployment-6sj54" not found
Run Code Online (Sandbox Code Playgroud)
如何删除豆荚?
我有一个.gz文件,里面有另一个文件。我需要提取压缩文件中的文件。
f = gzip.open(dest, 'rb')
Run Code Online (Sandbox Code Playgroud)
这只会打开文件,但我需要下载里面的特定文件,gz而不仅仅是打开gz文件。
这个问题已被标记为重复,我接受,但我还没有找到我们可以实际下载文件而不仅仅是阅读其内容的解决方案。提到的链接也是如此。
我有下面的代码片段:
amountLst = []
for i in range(9):
hsv = ""
if i == 0:
hsv = cv2.cvtColor(barc0Img, cv2.COLOR_BGR2HSV)
elif i == 1:
hsv = cv2.cvtColor(barc1Img, cv2.COLOR_BGR2HSV)
elif i == 2:
hsv = cv2.cvtColor(barc2Img, cv2.COLOR_BGR2HSV)
elif i == 3:
hsv = cv2.cvtColor(barc3Img, cv2.COLOR_BGR2HSV)
elif i == 4:
hsv = cv2.cvtColor(barc4Img, cv2.COLOR_BGR2HSV)
elif i == 5:
hsv = cv2.cvtColor(barc5Img, cv2.COLOR_BGR2HSV)
elif i == 6:
hsv = cv2.cvtColor(barc6Img, cv2.COLOR_BGR2HSV)
elif i == 7:
hsv = cv2.cvtColor(barc7Img, cv2.COLOR_BGR2HSV)
elif i == 8:
hsv …Run Code Online (Sandbox Code Playgroud)