Remove gradient from QToolBar in OS X - macos

I am writing an application in Qt, which uses QToolBar elements. In Linux and Windows, all looks OK. But in OS X, QToolBar have terrible gradient as its background. Please, suggest me, how I can remove it?
UPD.: I'm using Qt 5.2.

Have you tried QStyleSheets?
http://qt-project.org/doc/qt-5/stylesheet-examples.html#customizing-qstatusbar
http://qt-project.org/doc/qt-5/stylesheet-reference.html#background-prop
QStatusBar * bar;
bar = new QStatusBar;
bar->setStyleSheet("background: transparent;");
// bar->setStyleSheet("background: none;");
// bar->setStyleSheet("background: white;");
bar->showMessage("StatusBar");
Or if you are using it in the context of a QMainWindow, it probably would look like:
this->statusBar()->setStyleSheet( //...
Hope that helps.

The way above with QStyleSheet is correct. Another approach is to apply for example QWindowsStyle object with setStyle to QToolBar. QWindowsStyle is something that will have simple and standard look on every platform. I use it when I would like to have look&feel exactly same on all platforms despite different looks&feels on win/mac/unx.

It seems toolbar ignores styleSheets on Mac at all (at least in Qt 5.2.1). I was able to remove the gradient using the styles, for example using the Windows style. Toolbar buttons are not affected with it.
toolBar->setStyle(QStyleFactory::create("windows"));

This is a known bug also in 2020 with Qt5.12 (and probably Qt5.15). What works is setting a border (which might be zero to your stylesheet):
QToolBar {
background-color: palette(base);
border-width: 0px;
}
background-color alone does not seem to ensure that it's repainted.

Related

Appcelerator css-like calc method

I am using the Alloy framework to build a mobile application in Appcelerator Studio. To build the user interface i am using the *.tss files (sort of css) and using constants like Titanium.UI.SIZE or Titanium.UI.FILL for the width and height properties of the UI components.
I was wondering if there is a sort of css CALC method available in the Alloy framework, such that is possible to do size calculations like this:
width: calc(Titanium.UI.FILL - 20px)
height: calc(80% - 30px)
Thanks in advance!
If you are setting the width or height inside the .tss file, you have to set the value to an property of the Alloy global object (Alloy.CFG.yourVar or Alloy.Globals.yourVar).
alloy.js
Alloy.CFG.width = Ti.Platform.displayCaps.platformWidth - 20;
view.tss
"#myView":{
width:Alloy.CFG.width
}
If you set the value in your controller, you don't need to use like a global object property.
index.js
$.myView.width = Ti.Platform.displayCaps.platformWidth - 20;
http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Platform.DisplayCaps-property-platformHeight
TSS (Titanium Style Sheet) is not CSS. It purely declarative json file - but you can use some Titanium code inside it like Ti.UI.FILL or Ti.UI.SIZE or for translation you could use the L() function.
As a solution for having calculated values, I see 3 possible ways:
Pre-calculating what you need as part of an app bootstrap inside alloy.js, and storing it in alloy as part of a "namespace" - do note that it will reside on the "global scope" - but I don't think that's what's going to bring your app down. So you would have something like this:
Alloy.js:
Alloy.UI.MyScreen.MyComponent.height = DO YOU CALCULATION HERE;
ControllerStyle.tss:
"#myComponent" : {
height: Alloy.UI.MyScreen.MyComponent.height
}
Make sure you build your namespace right and use closures to not pollute the global scope.
For more information on alloy.js see here: http://docs.appcelerator.com/platform/latest/#!/guide/Alloy_Controllers-section-34636384_AlloyControllers-InitializerFile(alloy.js)
A second solution would be to use Dynamic Styles. See here: http://docs.appcelerator.com/platform/latest/#!/guide/Dynamic_Styles
Third solution would be to apply the properties you need in your controller code - this one is my least favorite because it forces you to "cross the bridge" between js and native when your controller loads and slows you down.
One thing you can do is pre-calculate it, another is set the calculated width not in tss but in the controller file.
What I tend to do, when I need to calculate something like this is pre-calculate this and use it throughout the app if there is more than 1 purpose of using it. Do this for example in alloy.js
Alloy.Globals.marginContentWidth = 300;
Or you can use any contant from the Ti Platform to calculate something. Now in tss you can use this
"#myUI": {
width: Alloy.Globals.marginContentWidth
}
This will work for you.
Another thing is not thinking about mobile UI like you do with a website. On mobile you need to think more flexible. One of the reasons you probably want width - 20px is because you want margin of 10px on both sides.
First off... don't use px. In mobile development you need points, or dp, but this is default so you can just use 20. To handle it more flexible, do this:
width: Ti.UI.FILL,
right: 10,
left: 10
This should fix your problem nicely
First of all .tss is not a sort of .css :), rather it is sort of json file.
Now what you want to do, you will need to learn Alloy & Titanium a bit deeper as you can do every sort of calculations in Titanium but there are other ways and perhaps since you are comparing it to .css, you are not getting it right.
So, I suggest you to first learn what Alloy & Titanium is and how they work and how they support each other.
You can always head on to the Titanium Docs which are absolutely clear to get you started on a right path. First give them a try, take time to learn things and we are always here to support you. :)
Good luck!

How to have compass create a data-uri for an image based on a css color name?

In working with a piece of legacy javascript, I've discovered that the only way to style a particular control is to set it's background image. This makes it a pain to support more than a couple of different background colors. What I'd like to do, then, is have compass generate the image at compile-time, and inline it as a data-uri. To a compass n00b, this seems reasonable, since each "background image" is just a square swatch of solid color.
Does anyone know of a project out there to automate this? Is it even a reasonable approach? If the "generate all the images in advance" approach is really the best, then I could probably manage that, but it seems far less elegant.
Thanks.
Use the compass-rgbapng like this:
body {
#include rgba-background-inline(rgba(0,0,0,1));
}

Issues with WIDTH and HEIGHT percentages in a DIV via CSS (firefox doesn't work)

My brain is overflow about this issue, so let me share my frustration in order to look for someone having the same experience and, luckily, finding a solution.
The thing is the following:
http://jsfiddle.net/w4d2E/
In chrome, percentages work fine, but when trying the same in Firefox (latest version) the content div is not expanding horizontally and vertically anymore.
I've analyzed every similar question over here, but I can't find any valid answer.
Thanks in advance
P.S.: I've tried to use block display instead of the 'box' one in the 'content' layer, but still having the same behavior.
You're using XUL box layout. I suggest not doing that. -moz-box is NOT CSS flexbox layout, as you seem to think.
The problem here is display: -moz-box for body. If you remove it everything works fine. It appears to be a bug, so I suggest filing a report in the bug tracker.

Customize List's cells in DashCode

I have my site created with Dashcode and I am using the List object but I don't like the default blue background when a cell is selected.
How can I customize this? For example change it to grey or white, etc.
(As far as i know, everything is customizable in Dashcode, is just sometimes you have to do it using code and not Dashcode UI.)
Thanks in advance.
Answer to my self:
looking at main.css I found something like:
.listRowTemplate_template.selected {
background-color: rgb(56, 0, 217);
}
Which is the color I want to change ;)
Which would have been my answer, shall i vote you up? ;-)
It is easy to forget that when in Dashcode it is "just" JavaScript, CSS and HTML and so many problems will often succumb to those type of solutions such as you have done.

Why flash on Mac does not display font correctly?

We have standard flex 3 project, and We have left everything as default, no change in style at all, and we deployed our project and noticed that on Mac the character spacing is very bad and overall look and feel is not as clear as that of windows.
Here is the difference, left one is Windows and right one is Mac.. the default flex font chosen by Adobe is "Verdana", the left one looks pretty, but right one looks as its width and character spacing, everything is incorrect. I assume verdana font may not be available on Mac, but in that case I supposed adobe should have given default standard font of good quality.
alt text http://akashkava.com/images/MacFlashFontProblem.png
What can we do to resolve this? Will embedding Verdana font in flex project style will help?
Mac OS X and Windows have different text rendering engines. I've heard it said that Mac OS X tries to preserve the character shape while Windows tries to align with screen pixels at small sizes.
That's going to result in differences between how fonts are rendered, and there's really no way to work around it.
Personally, I think the example on the right looks much nicer; the one on the left looks square, like it's being rendered at too small a size, while the one on the right looks more like the font is supposed to look.
It's not a solution, but Verdana is available on every OS X box. See this Apple doc for 10.5; I couldn't find one on 10.6 but there is one.

Resources