uitable updates behave strangely

조회 수: 2 (최근 30일)
Ali Komai
Ali Komai 2019년 8월 29일
답변: Ali Komai 2019년 9월 3일
I have a very peculiar problem. I programmed a trading application and ran into the following problem.
I have an uifigure and within this uifigure I have a tabgroup with two tabs. In this two tabs I have uitables showing the open positions of my application. One tab for stocks from the UK and one for US stocks.
Every 3 mins or when there was opened or closed a position the tables are updated. The update always affects only two columns per stock if the stock is already in the table. If it is a new position a line to the table is added.
So far so good, now comes the strange part. If I set a breakpoint right before the uitables are created and trace over the two lines both tables are created in their respective tab and all is fine. I can run the program from this point and it updates the tables just as I wish - great.
But if I don't set the breakpoint infront of the table creating lines and let the program simply run, the tables never show up in my tabs and are also not updated. That means not shown. I can go into debug mode and see and the data for both table is there in is also handled correctly, it is just not displayed on the screen.
I tried adding both a small pause after the uitable creation and also tried issueing drawnow but nothing helps. I have to trace over this two lines manually if I want to see my tables.
P.S.: Setting the breakpoint right after the two lines that are supposed to create the tables does not work. I have to execute the two lines manually to see the tables.
  댓글 수: 3
Stephen23
Stephen23 2019년 8월 30일
@Ali Komai: can you upload an MWE that shows this behavior?
Walter Roberson
Walter Roberson 2019년 8월 30일
Search for tag:always-parent

댓글을 달려면 로그인하십시오.

채택된 답변

Ali Komai
Ali Komai 2019년 9월 3일
The problem is solved by passing the data to the uitable function in frm of a cell-array instead of a table. Then everything works fine without pauses or anything special.

추가 답변 (1개)

Luna
Luna 2019년 8월 30일
I had that problem before, I simply solved it by changing the focus of the tabs while creating the uitables. Please try following steps I hope it works:
  • Make your first tab active, create the uitable inside of that tab. (Parent of the uitable should be a container in that tab)
  • Make your second tab active, create the uitable inside of that tab, too.
  • If you want to make an update then activate the corresponding tab, make your updates.
You should programatically make the activation by changing the SelectedTab property of your uitabgroup.
  댓글 수: 2
Ali Komai
Ali Komai 2019년 8월 30일
Thank you for the advise.
Luckily the problem was solved by a simple pause(3) after the uitable call (like I stated in my comment above). So a little patience was all that was needed. :-)
Ali Komai
Ali Komai 2019년 9월 2일
I do not really know what I'm doing differently, however the problem reoccured and no pause seems to alleviate it.
Therefore I tried now selecting the current tab programmatically like you suggest but this doesn't change anything. But maybe I'm doing it wrong.
If I set a breakpoint after the first uitable call the first table will be displayed. Do I set a breakpoint after the second call to uitable, only the second table is displayed.
Here is my code for creating the tabs and tables:
UIFigure = uifigure('Position',[200 220 1000 500]); % create status window
tg = uitabgroup(UIFigure,'Position',[100 240 800 240]);
tabUK = uitab('Parent',tg,'Title','UK','Scrollable','on');
tabUS = uitab('Parent',tg,'Title','US','Scrollable','on');
tg.SelectedTab = tabUK;
posTableUK = uitable(tabUK,'Data',positionsUK,'Position',[0 240 780 240],'ColumnFormat',{[],[],[],'bank','bank'});
tg.SelectedTab = tabUS;
posTableUS = uitable(tabUS,'Data',positionsUS,'Position',[0 240 780 240],'ColumnFormat',{[],[],[],'bank','bank'});

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by