I'm trying to print the content of a QTextEdit. For that I'm using QTextDocument::print(QPrinter*). Doing that, a page number is automatically added at the right bottom of the page.
Is there any way to change its format / move it / get rid of it?
Thanks.
As far as I know that is hard coded into Qt, so you can't change it.
Have a look at QTBUG-1688. There you see that this fact has already been reported, but they don't seem to work on it. So you will have to do it yourself, I think.
If you need that, there is an way. You can use
void QTextDocument::drawContents ( QPainter * p, const QRectF & rect = QRectF() )
Add your desired footer using this.. Obviously it isn't a good one but if you need it for sure, make use of it.
I haven't give a try though. But it should work.
Related
I am trying to get the icon of an app (doesn't matter which one). I noticed Qt doesn't have something like GDesktopAppInfo and therefore I tried getting it through QSettings from /usr/share/applications/appname.desktop. That's already a problem, because the desktop file might not be there. Anyway, going further to extract the Icon key. Now I dunno how to find the url (notice that I need the url, sure I could make a QIcon, but I need to export it to QML, which would mean another QQuickImageProvider class, anyway, I don't wanna go that way). Is it possible, or is the aforementioned QQuickImageProvider my only solution?
Here is a little guide that might help you find your way. Keep one thing in mind: start with the basic case, get code running and extend it to more difficult cases later.
For now, lets assume the following:
.desktop file is in /usr/share/applications
App icon is in SVG or PNG format
App icon path is absolute
App name is lower case and does not contain whitespace
Input: App name "git-cola"
Read /usr/share/applications/git-cola.desktop
Use a QRegularExpression to get the Icon value
You get an absolute iconPath, e.g. /usr/share/git-cola/icons/git.svg
Have an invokable C++ function that exposes a QUrl to QML
In QML, set the source property of an Image to getIconUrl("Target App")
where 4. looks something like
QUrl MyClass::getIconUrl(QString appName)
{
// get iconPath from appName
return QUrl::​fromLocalFile(iconPath);
}
If things are running, you can add support for
Multiple .desktop locations (there might be a handful or so)
Add support for relative paths
Add support for XPM files
You can use QIcon::fromTheme(QString iconName) to find the icon. It works most of the time but it's not as reliable as gtk
I am working in Sitecore 7 and want to customise the comments textbox. I need following functionality:
Instead of Single line, I want to replace it with multiline.
Is it possible to have rich text box instead of single line to allow users to put more meaningful comments and those are visible in History too.
You have to modify a lot to do it. When you approve button is called this command :
<command name="item:workflow" type="Sitecore.Shell.Framework.Commands.Workflow,Sitecore.Kernel"/>
with some parameters
Inside this class you have next method :
protected void Run(ClientPipelineArgs args)
{
...
where you find next lines of code that is called to show single line input :
...
if (!flag1 && flag2 && !flag3)
{
SheerResponse.Input("Enter a comment:", "");
args.WaitForPostBack();
}
Yes, this is possible, but you'll have to essentially recreate and replace some basic functionality to do it. And worse... it will require use of SheerUI, which is not documented anywhere from Sitecore that I know of. You have to figure it out by disassembling existing code. If you look at Sitecore's implementation of say, the Approve action, you'll see there is a SheerUI call to get the comment text. (not looking at it right now, so I don't know exactly where this is) You'll need to replace this with a SheerUI call to load your own custom dialog. How do you do this? Well... man, wouldn't documentation on this be nice?
hello i need make a auto adjustable QTextBrowser.
It's means the height of the QBrowserText depend of the number of rows it contained, somebody can help me please ?
Look at this page: http://qt-project.org/forums/viewthread/10240/
They used QDockWidget.
And here: http://www.mimec.org/node/383
I have managed to change the "color" property of QML text with C++ using this:
theText->setProperty("color", "red");
but if I try
theText->setProperty("font.pointSize", 20);
then nothing happens(it's not that size), I've tried this with other things that include a "." but none seem to work, I think the "." may be part of the problem. I'd really appreciate if someone could help me change the QML font size using C++.
Look for actual property name. And as far as i know there is no sub-properties in QObjects... So you need something like this:
QFont f = theText->property("font").value<QFont>();
f.setPointSize(20);
theText->setProperty("font",f);
Has anyone done this? Basically, I want to use the html by keeping basic tags such as h1, h2, em, etc; clean all non http addresses in the img and a tags; and HTMLEncode every other tag.
I'm stuck at the HTML Encoding part. I know to remove a node you do a "node.ParentNode.RemoveChild(node);" where node is the object of the class HtmlNode. Instead of removing the node though, I want to HTMLEncode it.
You would need to remove the node representing the element you don't want. The encoded HTML would then need to be re-added as a text node.
If you don't want to process the children of the elements that you want to throw away, you should be able to just use OuterHtml ... something like this might work:
node.AppendChild(new HtmlTextNode { Text = HttpUtility.HtmlEncode(nodeToDelete.OuterHtml) });
The answer above pretty much covers it. There's one thing to add, though.
You don't want to change a particular node, but all of them, so the code above will probably be a method, wrapped in an if statement ( to make sure it's a tag you want to HtmlEncode ). More to the point, since Agility Pack doesn't expose nodes by ordinal, you can't iterate the entire document. Recursion is the easiest way to go about it. You probably already know this...
I tackled a similar problem, and have some shell code (C#) you're more than welcome to use: http://dev.forrestcroce.com/normalizer-of-web-pages-qualifier-of-urls/2008-12-09/