Compare a color of labels in QML
How can I compare the color of the label in QML another color. My code below does not work as I expect. Despite the "scoreLabel" having the color "Color.DarkGray" if statements return true.
I also tried comparing it to the color of Color.create (), but it does not work as expected either.
if(scoreLabel.textStyle.color != Color.DarkGray/*Color.create("#f89e52")*/){ scoreLabel.textStyle.color = Color.DarkGray; //Otherwise make it orange. } else { scoreLabel.textStyle.color = Color.create("#f89e52") }
I'll try to experiment with the C++ export function too.
The following code seems to work:
// Navigation pane project template import bb.cascades 1.0 Page { Container { Label { id: label textStyle { base: style1.style } text: "Label text" } Button { id: button text: "Click me" property variant activeStyle: style1 onClicked: { if (activeStyle == style1) { label.textStyle.base = style2.style activeStyle = style2 } else { label.textStyle.base = style1.style activeStyle = style1 } } } attachedObjects: [ TextStyleDefinition { id: style1 color: Color.create("#ff0000") }, TextStyleDefinition { id: style2 color: Color.create("#00ff00") } ] } }
Exchanging directly colors should also work. Properties can be reallocated to enforcement.
OK, the C++ method also works. But I think that the States is the best.
QML:
// Navigation pane project template import bb.cascades 1.0 Page { Container { Label { id: label textStyle { color: Color.create("#ff0000") } text: "Label text" } Button { id: button text: "Click me" onClicked: { if (app.colorsEqual(label.textStyle.color, Color.create("#ff0000"))) { label.textStyle.color = Color.create("#00ff00") } else { label.textStyle.color = Color.create("#ff0000") } } } } }
Test.HPP:
#includeclass Test : public QObject { Q_OBJECT public: Test(bb::cascades::Application *app); virtual ~Test() {} Q_INVOKABLE bool colorsEqual(bb::cascades::Color color1, bb::cascades::Color color2); };
Test.cpp:
Test::Test(bb::cascades::Application *app) : QObject(app) { ... qml->setContextProperty("app", this); // <--------- ADDED AbstractPane *root = qml->createRootObject(); app->setScene(root);
...
bool Test::colorsEqual(Color color1, Color color2) { return color1 == color2; }
Tags: BlackBerry Developers
Similar Questions
-
Get the height a label in QML?
Can I get the height of a label in QML?
Or the coordinates of a container (up/down)?
BR, René
Container { attachedObjects: [ LayoutUpdateHandler { id: containerLuh onLayoutFrameChanged: { console.log(layoutFrame.x) console.log(layoutFrame.y) console.log(layoutFrame.height) console.log(layoutFrame.width) } } ] Label { text: "Label height: " + labelLuh.layoutFrame.height attachedObjects: [ LayoutUpdateHandler { id: labelLuh } ] } Label { text: "Container height: " + containerLuh.layoutFrame.height } }
-
Filter of color/side/Label/genre always grayed out?
In my LR 3.2 (Windows 7 64), orders of the submenu sub filter by color, side, Label, genre are still grayed out, regardless of the source (even with a new catalogue) or catalog. See the screen capture below. I know that I can activate filters and get this functionality by other means. But the menus are practical. Am I missing something painfully obvious? The aid does not seem to help.
John,
It seems that these filters can only be selected when the attribute filter is active in the filter bar (or by choosing 'Activate the filters' in the same menu).
Gossweiler beat
Switzerland
-
Can I change the colors of the labels on a slider programmatically? So far, I tried this:
char lblArr[3][25] = { "TOP\033fg990000\033bg009900", "MDL\033fg009900\033bg000099", "BTM\033fg000099\033bg990000" };for( i=0; i<3; i++ ){ ReplaceListItem (g_C9492_pnl, C9492_SLIDER_RING, i, lblArr[i], i+1); ReplaceListItem (g_C9492_pnl, C9492_LISTBOX, i, lblArr[i], i+1);}
The labels in the listbox control is not replaced, but they are not colored. The labels in the slider is not replaced, but the escape sequence are included in the text of the label (and they are not colored).
DRM for any help...
Hi BA,.
use escape codes for the listbox controls, you must set them before the text you want to assign. In addition, you must pass to the escape the real value of the color that you want to set (i.e. 0 x 990000), not its representation of string ("990000") as you do now. This code works colors assigned to the item in the listbox control:
int i;
char lblArr [3] [25];
sprintf (lblArr [0], "\033fg%06X\033bg%06XTOP", 0 x 990000, 0 x 009900);
sprintf (lblArr [1], '\033fg%06X\033bg%06XMDL', 009900 0 x, 0 x 000099);
sprintf (lblArr [2], "\033fg%06X\033bg%06XBTM", 000099 0 x, 0 x 990000);
for (i = 0; i< 3;="" i++)="">
ReplaceListItem (panelHandle, PANEL_LISTBOX, I, lblArr [i], i + 1);
}Unfortunately this is not possible on the rings of cursor (InsertListItems documentation mentions only listboxes when examining the color escape codes).
-
Hey guys,.
I wanted to ask a simple question. Is it possible to have a Label whose text contains several different colors. As in the example, assume that there is a label and its text is: "click here to open the notification history. I want to 'Click here' part to be blue and "history of notification" to be red. So the label will become
Click here to open the notification history.
Is there a solution outside the creation of 3 different labels and put them side by side?
Thank you for your help.
You should be able to do it with html
using the bar often allows research to solve a problem
-
Color of Label missing after upgrading to LR 2015.5.1.
My workflow in Lightroom is essentially based on the flags and color label. After the last update LR 2015.5.1 any label of color have disappeared while the s signs always available. Should mean that all marked images are now no while flagged images are always reported correctly.
I use creative cloud on Mac OS X 10.11.4 and did the update through the creative Application of cloud (as usual). My first idea was the issue could be assessed to the catalog. So I tried a backup of the catalog of before updating with the same result.
Any ideas or advice?
I thank you,
Norbert
In addition, select some photos that should be labeled and examine the label field in the metadata Panel:
The fields are empty?
-
This is illustrator
It's photoshop
Libraries are the same? The two RGB colors are different and they have different look on the screen.
None of this has to do if you are not working with color management and conversion of spot color to a CMYK process color, which seems to be the case here...
Mylenium
-
Change the color of the label dynamically in QML
How to change the base on the value of text color? For example, I want the text to red if the value is negative.
Hello
Here is an example:
import bb.cascades 1.0 Page { Container { Label { id: label textStyle.color: text < 0 ? Color.Red : Color.Green text: "100" } Button { text: "Click me" onClicked: { if (label.text < 0) label.text = 100 else label.text = -50 } } } }
Or, the legacy of the styles:
import bb.cascades 1.0 Page { Container { Label { id: label textStyle { base: text < 0 ? style2.style : style1.style } text: "100" } Button { text: "Click me" onClicked: { if (label.text < 0) label.text = 100 else label.text = -50 } } attachedObjects: [ TextStyleDefinition { id: style1 color: Color.Green // or Color.create("#00ff00") }, TextStyleDefinition { id: style2 color: Color.Red // or Color.create("#ff0000") } ] } }
If you compare the colors or export c++, here is another example on how to do this:
-
Track label/colors in my sequences are darker than usual.
The labels/colours of the tracks in my sequences are super dark now compared to how they were before. I have not changed anything other than the update. Is it possible for me to solve this problem?
Dark colors slowly steal my soul. In addition, it makes it difficult to see the track splits and transitions.
It was an intentional change in 7.2.2 based on comments from some customers that the colors of the clip are too bright in the timeline panel. Since this change, we have received comments from a number of unhappy customers how we implemented the change. In the light of this entry, we have other options.
In case you weren't aware, you can adjust the colors of label through the tab label good colors its name from the Preferences dialog box. But please note that due to the change of 7.2.2 colors will be darkened by 40% from the values that you set.
Here are three other threads on this topic:
-
Cascades label background color.
Hello
Is it possible to set the background color of the label? I would like to simulate a highlight on some of my labels but can't find anything in the docs that can do.
Thank you!
It is possible to style HTML text (I never got any work), but if you put the label in its own container, you can then set the background for the container.
Container { id: bunchOLabels Container { background: Color.Yellow Label { text: "Yellow" } } Container { background: Color.Blue Label { text: "Blue" } } }
-
Hello
I'm having some problems with color tags when you use lightroom;
I recently upgraded to Lightroom from 5.6 to 6.5, and all the photos of my catalog with tags color turns white label only.
I also have the same problem when I import pictures from my laptop catalog, whith photo colors such as red, blue, green, turns in a white label...
Is there a problem with LR 6.5?
Could you help me please?
Cosette
I finally found the solution.
During the upgrade, LR languages have changed, and the words associated with the colors too, labels
so I translate just the name of the color in the metadata / color label set / change, and everything is fine!
-
French color labels, in a version problem
In English:
Hello
I was testing with the beta and lightroom beta 2 version 3. Satisfied, I bought the french version 3 today. Unfortunately, I have a small problem:
color labels were not recognised during the transition to the commercial french version 3. The reason seems to be linked to a translation problem. Example: purple ("Purple" in french) is displayed not with the same color, but with the text, instead of the icon, "purpule. Same for the other colors.
How to get my color labels?
Thank you.In french:
Hello
I was testing lightroom with the beta and beta 2 of version 3. Satisfied, I bought the 3 French that day. Unfortunately I have a small problem:
colors the labels not been recognized during the transition to the 3 French retail version. The reason seems to be linked to a translation problem. Example: the color purple appears not with color advice, but with the text, instead of the icon, "purpule. Even chose for other colors.
How to get my labels to color?
Thank you.Snoopy,
I think that your hypothesis is correct, that your problem is caused by the different formulations in labels (I assume that you run LR3 Beta2 in English).
LR did wirte the word "Violet" in the column labeled your catalog when you have selected an image as violet. Now, with the french wording, LR interprets the word "Purple" in the purple label column, and nothing else. You can see these metadata associations in the library Module, menu / color label set up / change.
To solve your problem, I'd do the following for each color labels:
- Activate the metadata, with the 'label' showing column filter
- filter on a specific label term (for example, "Purple")
- Select all filtered photos
- Mark it as "Purple".
This will redefine the terms (French) to your photos.
Gossweiler beat
Switzerland
-
Hi all, I have the following code example
function test() { var col = Color.create(1.0, 0.5, 0.3); return col.green(); } Label { text: test() }
And the test() function returns nothing. I have no idea why. I expect that it must return a value of 0.5. What I am doing wrong? Any help?
Hello
It seems that the color functions are not what QML:
float const green();
A possible workaround is creation of helper functions in C++ to access members of the color. The second example in this post shows how object Color can be passed QML for C++:
An important point: in this code, the colors are passed by value. Passing by the pointer will not work, because the pointer is not declared as meta-type in the headers of Cascades.
-
Quota of change in QML container
This doesn't seem to work:
Container { layout: StackLayout { orientation: LayoutOrientation.LeftToRight } Container { id: cnLeft property int quota : 50 layoutProperties: StackLayoutProperties { spaceQuota: quota } background: Color.Red Label { text: "Left" } } Container { id: cnRight property int quota : 50 layoutProperties: StackLayoutProperties { spaceQuota: quota } background: Color.Blue Label { text: "Right" } } }
Basically, it ignores the quota... unless I hard code the values in the spaceQuota property.
Is it possible to change the quota AFTER qml has been loaded. (for example, if the length of text changes I want to readjust the parameters of quota accordingly).
Thank you
If you want to implement the logic to make the adjustment in QML I think it would be something like this:
function readjustContainers() { // whatever logic if (cnRight.needsToBeAdjusted()) { cnRight.layoutProperties.spaceQuota = newQuota; } }
See if it works.
-
pass data from childCardDone to a textfield in QML?
I have a card camera call function that responds with the path of the image once a picture is registered using the childCardDone function. I have no idea how to pass data from c ++ to qml. I know that during the passage of the QML for C++ database, you set a QString & something. How can I do the reverse?
Here's my CPP code:
void App::childCardDone(const bb::system::CardDoneMessage &message) { if (message.reason() == "done") // Need the message.data() info in my QML message.data(); qDebug() << message.reason() << "\n"; qDebug() << message.dataType() << "\n"; qDebug() << message.data() << "\n"; } public slots: void childCardDone(const bb::system::CardDoneMessage &message);
and I just want to get the value of message.data () into a textfield label in QML:
Label{ id: capturedFilePath text: <
> } All help is appreciated and will be loved and accepted as a solution if it works.
Thanks in advance.
For use in your function you will need to decalre in the header.
In the header to declare,
AbstractPane * root;
Then, change
AbstractPane * root = qml->
() createRootObject; TO
root = qml-> createRootObject
();
Maybe you are looking for
-
Upgrade memory of HP Pavilion Dv5t-1100 CTO Question
Hello world:I own a laptop HP Pavilion DV5t-1100 CTO Notbook of customizable entertainment... Model number: FL773AV and CNF8471PML series number. My OS changed to Windows 7 Professional. My number of parts of current memory cards are 48468-001, 2 GB,
-
My "wireless connection" screen does not show available networks, but gives me the message "Windows cannot configure this wireless connection". Should what changes I make to connect to different wireless routers?
-
HP Probook 4720 s hard disk crash?
It starts all the way, when I run diagnostics in the system it says: Test drive: FAILURE Starting test: FAILED I tried reinstalling the HDD, has not helped. I'm pretty sure I have to replace my hard drive, BUT if I start it, I actually get a screen o
-
HP Envy 7640: HP Envy 7640 does not print colours, envelopes or labels
My Hp Envy 7640 is only a little over one year old. Last month, it stopped printing color. I tried to install two new cartridges HP... nothing helps, it does not color print and he always tells me that the ink level is low. I am also unable to prin
-
Should I create pagefile on ramdisk with my new SSD?
Hello Got my new SSD which is the only drive in my system now. To avoid the heavy writing on this drive, I bought Superspeed Ramdisk more (IE temporary files etc.). I have Windows Vista Business 32-bit with 4 GB of ram. The Ramdisk software is able t