How to display a QLabel under another QLabel? - qt

I have some QLabels in a QWindow. They might have some space in common. I want to know how can I change label's depth. In default situation the label which defined later is on the previews ones.

You can define an indent for each widget and call raise_ function in sort of their indent.
for label in labels:
label.raise_()

you should use raise, like :
labelname.raise_()

All widgets have methods for this.
widget.stackUnder(another_widget) #relative postition
widget.lower() # send to the bottom
widget.raise_() # send to the top
See documentation on QWidget

Related

QTextEdit: How to add fixed position text on top of an image

I am using QTextEdit to implement an editor. One of the requirements I have is to add fixed position text on top of an image.
For example:
I have an image of dimensions: 300x300. I need to add text beginning at the location (20, 20) of the image and ensure that the text does not flow beyond the width of the image.
Something like below:
I am thinking that if I can add a QGraphicView, I can add the image and position text appropriately. Is this possible? Is there a way to introduce a graphic element into a QTextedit? If not, what is the right approach?
Is there a way to introduce a graphic element into a QTextEdit? If not, what is the right approach?
You could look at this the other way and add the QTextEdit to a QGraphicsScene. The graphics scene provides a QGraphicsProxyWidget to add standard Qt widgets.
Therefore, you could create a QGraphicsScene and QGraphicsView. Add a QGraphicsPixmapItem for the image and add the QTextEdit item with a call to QGraphicsScene::addWidget, which returns a QGraphicsProxyWidget, allowing you to position, scale and resize the widget.
Alternatively, you could start with a QGraphicsItem, inherit from that and create your own object which encapsulates the image and proxy object of the QTextEdit.
There are other ways of tackling this too, but I'd probably go for the custom QGraphicsItem. It also depends on your specification, but you can add text items in a graphics scene, without the QTextEdit, though you'd probably have to implement the editing feature, if this is required.

How to make a layout invisible in Qt?

I add a layout in a dialog and sometimes I want it and all its containing widgets to hide. How to implement it? I try layout->setEnable(false), but it doesn't seem to work in my tests.
You can't do that. You should add a widget in your form, put children inside the widget and assign desired layout to the widget. The behavior will be generally the same, but you can use setVisible or hide methods of the widget.
Transform QLayout to QWidget first, then you can use QWidget->hide().

Individual QTreeWidgetItem indentation

Is it possible to have individual indentation of items in a QTreeWidget?
In specific, I have have a column containing both text, icon and for some of them a CheckBox. The items without a CheckBox gets shifted to the left so the indentation of the icon and the text is not inline with the others. Could maybe be fixed with a hidden CheckBox if that is possible?
Maybe the use of Delegates will give you a nice and proper implementation. You'll have the opportunity to re-implement the paint() and sizeHint() methods, and therefore, choose the way your QTreeWidgetItem are being drawn...
More documentation here : http://doc.trolltech.com/4.6/model-view-delegate.html
An example : http://doc.trolltech.com/4.6/itemviews-pixelator.html
Hope it helps a bit !
You can try using the QWidget::setContentMargins() on the widget returned by QTreeWidget::itemWidget().

Tree dataTipFunction tooltip Change position,Flex3

I am doing dataTipFunction on Tree in Flex3 Air,
At present the tooltip hides the present node, i need to reposition the tooltip above the node, how can change the x,y position of the tooltip.
Thanks in Advance
The way I did this was to add the toolTipShown listener on the tree itemRenderer, not on the tree. I have a blog post that shows you how to do it, including the code for positioning the tooltip below or above the node.
Hook into the tooltipShow event on the Tree and move the tooltip yourself (a reference to the tooltip is in the event)
tooltipShow
You might need to do a bit of logic to position it correctly, and you'll probably want to check if repositioning it would move it off screen and move it below instead in that case.

Flex mx:axisrenderer How do I prevent the labels from being scaled

I have a line chart that sometimes contains a number of data points. I have solved how to prevent the horizontal axis from displaying too many labels using custom label functions and data functions. My problem is forcing the AxisRenderer not to scale down my labels.
I'm using the labelRotation property so the canDropLabels and canStagger properties are not an option.
Thanks in advance for any replies.
Try use gutter, gutter set are for the axis labels (if you want u can try to read the code of the AxisRenderer, and see how it use the gutter and other parameters to scale if need the text.
You can set the gutter by style like this (this work for me):
LineChart {
gutterLeft:50;
gutterRight:50;
gutterBottom:50;
}
I believe this can be done by editing the labelRenderer property. Take a look at the second example on this page (Formatting charts), they define a custom component to use as the label. You can do something like that to maintain whatever look you want.
I ran into the same issue. In my case (for the data that I'm plotting), simply setting canDropLabels to true (either in ActionScript or MXML as below) resulted in widening the margins allocated (I'm guessing) to the label text in the chart such that I never saw the text render smaller than set by fontSize below. Try it, it may be all you need.
hAxisRenderer.setStyle("canDropLabels",true);
...
<mx:AxisRenderer id="hAxisRenderer" placement="bottom"
tickPlacement="inside" tickLength="8"
canStagger="false" canDropLabels="false" fontSize="12">
For reference: http://blog.flexexamples.com/2007/10/16/dropping-labels-in-a-flex-chart/

Resources