Adding space between image and text in QPushButton - html

I have a rich text button, which is a descendant of QPushButton and uses QTextDocument for limited HTML support. I need to create a button, which has an icon on the left and a caption on the right (with some space between image and text).
So, let's assume that we have set_html(const QString& html) method. I failed to add the space between image and text via style attribute (with margin) in img tag. What will be the input string for that method?

You can try the following verbose workaround (due to limited HTML support in QLabel):
<table><tr><td><img src=":/save_monitor_settings.png"/></td><td style="padding-left:10px;">Some text</td></tr></table>

Related

Knockout JS removes extra space contained between two words while binding it to ko.grid

Could any of you please provide the solution that why knockout JS removes the extra space when I am binding to the grid.
For example, I am getting the below data for a column from the database.
"I am a developer"
I have given two space between "a" and "developer" but when it binds with the grid, it removes the extra space and make it as "I am a developer".
How can I preserve the spacing?
This is not a knockout problem, is about the way your HTML is displayed in the browser.
Your HTML renderer (browser itself) is taking those two spaces and combining then into one. Adding the empty HTML char code for white space ( ), forces the browser to display an empty space it.
Also, check this HTML tag <pre></pre> for preformatted text which renders the text as is. From the W3C schools:
Text in a element is displayed in a fixed-width font (usually
Courier), and it preserves both spaces and line breaks.

CSS sprites for maximum accessibility?

Suppose I want to replace a link > with a fancy image arrow. For that I want to use a CSS sprite.
In many articles, for example in a recent (2012) article in Smashing Magazine, the recommended method is something like this:
HTML:
>
CSS: hide text and specify sprite as background
However this method is problematic concerning accessibility: If images are disabled but CSS is interpreted, then the above link will be invisible.
Interestingly, I found an old (2010) article by Paciello Group that proposes what looks like a good solution. The idea is to place a <span> next to the text to be replaced. The <span> has a background image and is positioned on top of the text. If the image loads, it replaces the text, otherwise the text is still visible.
Why is this method not widely employed? Are there issues with that solution?
The main disadvantage is showing the text to users with no special accessibility needs, before your CSS sprite loads. In terms of code, it is also perhaps not as semantically clean as using an aria-label solution (explained below).
You could consider using an ARIA label for the element:
The aria-label attribute is used to define a string that labels the current element. Use it in cases where a text label is not visible on the screen.
https://developer.mozilla.org/en-US/docs/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-label_attribute
I quickly checked how Gmail and Facebook approach this problem (buttons without text):
In Gmail the 'previous' button has an aria-label of 'Older'
in Facebook the 'cog' icon in top right has some text 'Account Settings' indented -5000em

Sliding doors for input text

Is it possible to use the sliding doors css tehnique for input text? I've used it in 'button', but it doesn't seem to work with input types.
You should put the input tag inside of a span or div and then do the sliding doors technique. If you don't want to add the extra tag, use multiple background images. It is important to note that this isn't supported by every browser.
About multiple CSS background images: http://css-tricks.com/css3-multiple-backgrounds-obsoletes-sliding-doors/

Better add images through html or css?

Better add images through HTML and determine alt tags, or add through CSS with the text-indent: -9999px (or similar) property? Or is there no difference?
Does search engines take text-indent: -9999px property as a normal way of doing things? Cause with this property we actually create a text, but not showing it for the user.
I'd say it depends on what you're trying to make it mean. Is it an image with text fallback, or is it text with an image enhancement?
If I have an image which is just a fancier version of the text (perhaps with special effects or flourishes), I use the text with background-image and negative text-indent. If I have an image where the text does not convey the full meaning, I use <img alt>.

If the tabs use all images to show text + icon on each tab, then how to add text to to help search engine to find the keywords on the tabs?

Especially each image that contains the text and icon are displayed using background-image in CSS (using CSS Sprites), so there is no even alt or title if the image
had been shown using <img>. So, pure image in this case. How can actual text be added (or using some other mechanism) for search engines to better index these tabs?
You'd use an 'image replacement technique':
http://www.mezzoblue.com/tests/revised-image-replacement/
Just use actual relevant text in each element and use text-indent:-9999em; to shift it offscreen. This may involve extra styling such as display:block on the element if it's normally inline for text-indent to work but you'll end up with basic a CSS image replacement implementation.
You should absolutely be using text somewhere, at least an alt tag.
Try a something like <span>Text</span> with text-indent:-9999px;, or any of the other variations of css text hiding/masking.
There may be some merit to adding the title attribute to those tabs as well.
If you use a <span> and set its display to none via CSS, then you can put whatever text in there you like for SEO.
This is done on i.e. <h3> tags on the css Zen garden. A number of them use this construct:
<h3>
<span>The Road to Enlightenment</span>
</h3>
...where you then give the <h3> a CSS background-image and set the <span>'s display to none. You should be able to use the same type of idea for tabs that use images.