MATLAB Answers

display an icon (in png format) in a cell of a uitable

조회 수: 14(최근 30일)
Varsha 9 Feb 2011
I need to build a table that displays the status of a service in a GUI I am working on. I am using the uitable to display this information. In the first column I need to place the required icon (tick if on, cross if off etc). I can't seem to find how to do this anywhere. I have no clue at all. Please help.
Thanks. Varsha

  댓글 수: 0

Sign in to comment.

채택된 답변

Nicolas 13 Jun 2011
actually you nearly had it.
the problem is your html code.
properly it should say:
'<IMG SRC="">'
...and it works!

  댓글 수: 4

표시 이전 댓글 수: 1
Walter Roberson
Walter Roberson 13 Jun 2011
Well, except for the semi-colon near the end: the Answers comment system automatically inserted that for me :(
Jan 13 Jun 2011
@Walter: Even the browser does not find a logo.tif at - try it: . In consequence the broken link icon is not a failure.
Jan 13 Jun 2011
@Nicolas: Although it is nicer, you do *not* have to close HTML tags in the UICONTROLs.

Sign in to comment.

추가 답변(1개)

Walter Roberson
Walter Roberson 10 Feb 2011
There is no documented way to do this.
You can take advantage of the fact that text cells will be interpreted as HTML if they are in the proper format, such as
'<HTML><IMG="" >'
Using that I have been able to get the "broken link" icon, but I have not yet been able to get an actual image up. And you have to do nasty things to cell widths and fontsize to make room for the image.
If there is a mechanism for this, it would probably be described at Yair's undocumented matlab site

  댓글 수: 1

Jan 13 Jun 2011
Try an existing and local file:
pic = fullfile(matlabroot, 'toolbox', 'image', 'icon', 'icon_info.png');
uitable('Data', {['<html><img src="file:/', pic, '"></html>']})

Sign in to comment.

Translated by