适用于整个窗口宽度 [英] Uitable over whole window width

查看:114
本文介绍了适用于整个窗口宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以编程方式(或在GUIDE中)修复是初始化时面板的整个宽度.我怎样才能做到这一点?

I would like to programmatically (or in GUIDE) fix the matlab-uitable to be the whole width of the panel on initialisation. How can I do this?

我所要做的就是更改单列的像素大小.我希望当时的uitable是页面宽度的100%.当窗口以最小化形式显示时,GUI看起来很好,但是当我最大化它时,uitable仅为页面宽度的一半. (虽然uitable的高度不是整个面板的高度,大约是整个页面的1/2)

All I've managed is to change the size in pixels of single columns. I would like the uitable to be 100% the width of the page at that time. When my window is in minimized form the GUI looks fine, but when I maximize it, the uitable is only about half the width of the page. (The uitable's height is not that of the whole panel though, around 1/2 of the whole page)

GUI使用.

这是我现在正在尝试的代码:

This is the code that I am trying right now:

data = populateTable;
parentPosition = get(handles.uipanel4, 'position');
uitablePosition = [x y parentPosition(3)-2 parentPosition(4)-2]; 
set(handles.uitable, 'Position', uitablePosition);
set(handles.uitable, 'Visible', 'on'); 
set(handles.uitable, 'Data',data, 'ColumnFormat',{'numeric'});

推荐答案

可能的解决方案是将figure和表的position都设置为normalized,然后设置表到[0 0 1 1]

A possible solution could be to set both the position of the figure and of the table to normalized, then to set the position of the table to [0 0 1 1]

f = figure
set(f,'unit','normalized')
set(f,'position',[0.1 0.1 0.5 0.5])
data = rand(13);
for i=1:length(data)
   col_names{i}=['Col. # ' int2str(i)];
end
for i=1:length(data)
   row_names{i}=['Row. # ' int2str(i)];
end
t = uitable(f, 'Data', data,'unit','normalized', ...
   'Position', [0 0 1 1],'columnname',col_names, ...
   'rowname',row_names);

这篇关于适用于整个窗口宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆