I want to use HTML format in QToolButton. for example in this picture , I should create QToolButton in "Sara" and "Online".
Here is my code:
viewControl=new QToolButton(this);
QString labelText = "<P><b><i><FONT COLOR='#fff'>";
labelText .append("Sara");
labelText .append("</i></b></P></br>");
labelText .append("online");
viewControl->setText(labelText);
But it seems QToolButton cannot define HTML format.
How to resolve it?
I also used layout in QToolButton but it show me empty box.
QVBoxLayout *titleLayout = new QVBoxLayout();
QLabel *nameLabel = new QLabel("Name");
QLabel *onlineLabel = new QLabel ("online");
titleLayout->addWidget(nameLabel);
titleLayout->addWidget(onlineLabel);
viewControl->setLayout(titleLayout);
According to the answer mentioned here
I don't think this is possible without subclassing QToolButton and overriding the paintEvent. but you can try something like this:
toolButton->setStyleSheet("font-weight: Italic");
Related
I am trying to add a custom element into a editable div using document.execCommand detailed at https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand.
But when I try to add a custom polymer element using the execCommand, browser is unable to recognize the custom element even if it was already imported into scope.
var video-id='FnoL3d33U8o'//a youtube video Id
var html = '<p><div><custom-video-element width="454" height="280" video-id="'+videoUrl+'"></custom-video-element></div></p>';
document.execCommand('insertHTML', false, html);
But this doesn't help and the custom-video-element is not recognized by the browser. Please help if there is any alternate ways or if I am running after a mirage!
if you know what element you need to append, then you can use document.createElement.
There are multiple options how to achiev that, but In your case:
var p = document.createElement("p");
var div = document.createElement("div");
var custom = document.createElement("custom-video-element")
custom.setAttribute("video-id", videoUrl);
.. setting another attributes ..
div.appendChild(custom);
p.appendChild(div);
document.appendChild(p);
and that is it. This should work well.
Of course there might be better and easier solutions but in your case this isn't so bad.
if you create bigger html structure inside your JS, you will do something like:
var div = document.createElement("div");
var inner = "<div class="test"><div></div><p class="p"></p></div>;
div.innerHTML = inner;
div.querySelector(".p").appendChild(document.createElement("custom-video-element"));
Im using ITextRenderer to generate a pdf file from html and css, I have a footer with the current page on the right.
But now i would like to have the current date on the left.
I found this:
<div data-line="1"></div>
div[data-line]:after {
content: "[line " attr(data-line) "]";
}
But I dont know how to combine it with :
#bottom-left {
content: "Date: ";
}
Is this possible or is there any other way?
I would like the footer to look something like this:
Date: 2015-03-17 12:04
UPDATE 1:
I have a method createPDF(string html, String resourceUrl), that looks like this:
ByteArrayOutputStream out = new ByteArrayOutputStream();
HtmlCleaner cleaner = new HtmlCleaner();
TagNode node = cleaner.clean(html);
CleanerProperties props = cleaner.getProperties();
new SimpleXmlSerializer(props).writeToStream(node, out, "ISO-8859-1");
ITextRenderer renderer = new ITextRenderer();
renderer.setPDFVersion(PdfWriter.VERSION_1_7);
renderer.setDocumentFromString(new String(out.toByteArray(), "ISO-8859-1"));
renderer.getSharedContext().setBaseURL(resourceUrl);
renderer.layout();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
renderer.createPDF(outputStream);
renderer.finishPDF();
outputStream.flush();
outputStream.close();
return outputStream.toByteArray();
The example that you cite of using data-line in the CSS is an interesting way to dynamically generate CSS based on data-* HTML attributes. These in turn might be dynamically generated in a web page by a server-side or client-side script. But it seems like this might not be the appropriate method for your case.
If you are already using a Java class like ITextRenderer to generate this PDF, then the best method for you is probably just to use Java itself to generate the current date in the format that you want, then print that directly into the CSS as a string.
If you are loading the CSS from a manually created file, one way to do this would be to write your CSS with some text you intend to replace, for example INSERTDATE. Then in Java, load your document the way you normally do, then use some Java code like String.replace() to replace INSERTDATE with today's date.
Update 1:
Based on your sample code above, you could write INSERTDATE where you want the date to appear in your HTML/CSS, then call:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); # your desired format
String strDate = sdf.format(new Date()); # get the current date
html = html.replace("INSERTDATE", strDate);
at the top of your method.
You can use css string-set with content() and string() css functions , see https://www.w3.org/TR/css-gcpm-3/ like :
<div class="where-content-comes-from">1</div>
<div class="where-content-is-injected"></div>
.where-content-comes-from{
display:none;
string-set: am-just-a-var content();
}
.where-content-is-injected:after {
content: string(am-just-a-var);
}
bonus : you can also use css env() function to display date value see https://developer.mozilla.org/en-US/docs/Web/CSS/env
In actionScript,am trying to change the text area using setSize()here is the code..please help me
var prbDesc_txt:TextArea = new TextArea();
prbDesc_txt.text = "Hello world!";
reportAProblemPopUp.addChild(prbDesc_txt);
reportAProblemPopUp.prbDesc_txt.setSize(100,100);
Here am trying to add the textarea to reportAProblemPopUpmc.
Instead of:
reportAProblemPopUp.prbDesc_txt.setSize(100,100);
remove the reportAProblemPopUp and just reference it directly:
prbDesc_txt.setSize(100,100);
Otherwise you need to use getChildByName() on your reportAProblemPopUp if you want to reference it the way you were thinking of.
What is the best way to convert a tlf markup to HTML? I want only standar HTML without the old font tag. I think I saw a utility created by someone for this, but I can remember where it is. any ideas?
Tks.
http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3_Flex/WSc3ff6d0ea7785946579a18b01205e1c5646-7fef.html
var ptext:String = "Hello, World";
var flow:TextFlow = TextConverter.importToFlow(ptext, TextConverter.PLAIN_TEXT_FORMAT);
var out:XML = TextConverter.export(flow, TextConverter.TEXT_LAYOUT_FORMAT, ConversionType.XML_TYPE );
but use TextConverter.TEXT_FIELD_HTML_FORMAT instead of TextConverter.PLAIN_TEXT_FORMAT
Hallo all: I need to insert a html string in a iframe as shown below:
....
var html = "<html><head><title>Titolo</title></head><body><p>body</p></body></html>"
jQuery('#popolaIframe').click(function() {
parent.$("#indexIframe")[0].documentElement.innerHTML = html;
});
Is there a way to achieve this?
var html = "<html><head><title>Titolo</title></head><body><p>body</p></body></html>"
jQuery('#popolaIframe').click(function() {
var doc = parent.$("#indexIframe")[0].documentElement;
doc.open();
doc.write(html);
doc.close();
});
Does that code you posted work? If not, it's probably because browsers disallow modification of iframe content for security reasons.
Looks like you can get a refrence to the body so I don't see why not:
http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_iframe_contentdocument
You have lost 1 level, you need modify innerHtml of body, but not document:
document.body.innerHTML = bla-bla
You cannot insert into an iframe unless you remove() the iframe and use 'append(html)'. You can insert it inside iframes body like
$('body',parent.$("#indexIframe")[0].contentWindow.document).html(html)
Alternitevely if not sure about the parent element you could do that:
var doc = $.find("#myIframe")[0].contentWindow.document; //that will look in the whole dom though
doc.open();
doc.write(html);
At least this did the job in my case :)