I am using a PtMultiText widget to display log events. I would like to print one event per line in the widget and to associate a color to distinguish events.
I wonder if there is an easy way to colorize the full line (beyond text wrap limit) instead of text (text_color attribute), because I am not statified with the graphical result. Because each line of text does not have the same width, this is not harmonious. Or maybe is there a way to add columns to the widget and to colorize each cells separately.
Here is a snippet of code:
[code]/** Check code event to determine if FAULT, ALARM or INFO type
*/
PtMultiTextAttributes_t lattributes;
char lstatus[10];
lattributes.font = Pt_DEFAULT_FONT;
if (sevents.events[lcindex].code < 100) {
if (sevents.events[lcindex].code == 6) {
lattributes.background_color = Pg_RED;
lattributes.text_color = Pg_DEFAULT_WM_COLOR;
strncpy(lstatus, "[ALARM] ", sizeof(lstatus));
} else {
lattributes.background_color = Pg_GRAY;
lattributes.text_color = Pg_DEFAULT_WM_COLOR;
strncpy(lstatus, "[STATUS] ", sizeof(lstatus));
}
} else if ((sevents.events[lcindex].code < 400)
&& (sevents.events[lcindex].code >= 100)) {
You’ve probably looked at the documentation already, so I suspect that the PtMultiText Widget is not going to do what you want. Have you considered using a container or list containing text widgets?
I can’t use text widgets nor containers because I have up to 1000 events to display!
That’s why I use this widget with a scrollbar.
I tried some tricks like strings with spaces padding but unfortunately it doens’t do the work
My lines have not the same size …
I figure someone has already try to do something similar and looking for tips aroun here!
I’ve posted an answer to that yesterday but the response is still not published for a reason I ignore.
Do you have an example with list and text widget added dynamically ?
All I asked was for you to explain this statement. Why is 1000 events a problem?
I infer from your response that 1000 is not the problem, but that you don’t know how to deal with lists.
The place to start is the documentation. It might help to focus on the fact that QNX widgets
are hierarchical. To know what a widget is capable of you, have to check it’s properties in the documentation, and the properties of it’s ancestors.
All widgets descend from a PtWidget which has basic properties. Widgets that will display on the screen also descend from a PtBasic (which descends from a PtWidget).
The most basic container widget is a PtContainer. This widget adds the ability to contain other widgets.
PtList and PtRawList are descendants of PtContainer so they too can contain widgets. They each add features which may or may not be useful to your application. To find out, you will have to look at their properties.
Given what I know, I think the most straight forward solution for you would be start with a PtScrollContainer, and add PtText widgets to it. You create the PtText widgets using PtCreateWidget() giving them the PtScrollContainer as the parent. There are args, nargs parameters to PtCreateWidget() which allow you to set the text and background color at creation time. You will need to position the text widgets yourself in the scroll widget. You can use either the Pt_ARG_AREA or Pt_ARG_POS properties to set this.
I mentioned PtList because I think it handles the positioning for you, but that doesn’t mean it’s the right choice.
Yes I do but as far as I know, Qt is not part of momentics IDE yet and I was short of time at the time to try Qt and compile the GUI separately from momentics.
That’s the reason why I started with Photon on this project.
It will be interesting if they do. A Qt project is a C++ project using the Qt libraries. So you can make a Qt program with the IDE. The reason I say interesting is that along with the different versions of Qt, there are two major branches. One branch has a GNU license. The other has a commercial license. So which would QNX provide?
On top of this, the current port of Qt works on top of the gf layer. This will change with the next version of QNX as both Photon and gf are going away.