I'm just a beginner to QML and I wanted to make a simple example, which contains just one Rectangle with a TextEdit element:
import QtQuick 1.0
Rectangle {
width: 400; height: 400
color: "lightblue"
TextEdit {
x: 50; y: 100; width: 300; height: 300
text: "editable text editable text editable text editable text "
font.family: "Helvetica"; font.pixelSize: 32
}
}
The idea here is to just have a few lines displayed that the user can change or add. I just would like it to display it as multiple word-wrapped lines instead of just on a single line. I don't even need a scrollbar. Since TextEdit does not have a WrapMode property, how can I do this? :-(
Thanks!
Nina
TextEdit has a wordWrap property.
See http://doc.qt.nokia.com/4.7/qml-textedit.html#wrapMode-prop.
if you add
wrapMode: TextEdit.WordWrap
to the TextEdit component the text is wrapped to multiple lines.
Related
How can I scroll to a particular line in a multiline, rich text QML TextArea? There is positionToRectangle but that only accepts a position as an int which doesn't seem suitable for multiline text.
I suggest trying to calculate the position based on the line number multiplied by line height. You can calculate height of one line like this:
(textArea.implicitHeight - 2 * textArea.textMargin) / textArea.lineCount
This might help you to use positionToRectangle.
edit: as an afterthought, have you tried setting cursorPosition?
A TextArea is not scrollable by itself (cf Scrollable TextArea):
If you want to make a TextArea scrollable, [...] it can be placed inside a ScrollView.
Then you just have to set the contentY of your contentItem:
ScrollView {
id: view
width: parent.width
height: 60
TextArea {
text: "A\nB\nC\nD\nE\nF\nG\nH\nI\nJ\nK\nL"
}
}
Button {
text: "scroll"
onClicked: view.contentItem.contentY += 10
}
I'm using d3 and nvd3 to visualize some data in a graph. Now, no matter how many graphs i have, the legend above the (line)graph will always be shortened with trailing dots at the end.
Is there a way to adjust the legend in a fairly comfortable way? If so, how would i adress the legend and its properties?
I found the answer myself.
To keep the text from shortening, you can use chart.legend.align(false)
Thanks Reteras it did the trick for my PieChart, here are my legend chart options (typescript version)
Just change the margin to adjust the position
legend: {
align: false,
height: 200,
margin: {
right: 50,
top: 25,
left:0
}
}
legendPosition: 'right',
legend: {
maxKeyLength: 100,
padding: 40
}
This will set maximum text length of legend as 100 and ensures text cut off due to ellipsis.
Here is the plunker created http://plnkr.co/edit/5DhDmI1Odhrys4jYDwIB?p=preview
I have associated textbox with ng-grid filter.
$scope.filterOptions = {
filterText:''
}
$scope.$watch('filterText',function(){
$scope.filterOptions.filterText=$scope.filterText;
});
If you enter "moroni" in the text box, only one row in grid will be displayed. But at the right, white space is visible. Is there a way to fix it.
First row in the plunker example is having very big string, When text is very long, only part of it is displayed. Is it possible to break the string and display it in multiple lines.
You can fix the text not wrapping issue by setting the rowHeight in gridoptions to value that fits your longest string:
rowHeight:50
And add this definition to your css:
.ngCellText {
white-space: unset;
}
The width whitespace issue is clearly a bug in ng-grid. This grid is not really a table but a lot of positioned and measured divs that look like a table. Seems the developers forgot to add some extra width to the row when no scrollbar is visible. You can only overcome this if you patch the code (not recommended) or setting the gridheight to a value in which all rows can be displayed without scrollbars.
.gridStyle {
border: 1px solid rgb(212,212,212);
width: 500px;
height: 300px
}
Look at this Plunker.
Anyhow, since these are mere unpractical hacks, I suggest you have a look at table based directive like trNgGrid which has all the features of ng-grid but is way more flexible when it comes to dynamic row heights.
I'm using kendo tooltips on a graphic (within an anchor link) which is 24px tall. Accordingly, when the tooltip shows up (default position of bottom), it covers the bottom third of the graphic and so the bottom third of the graphic can't be clicked.
I can do the following:
.k-tooltip {
margin-top: 8px;
}
But the problem with this is that if the tooltip is on a graphic at the bottom of the page, the position will be "top" instead of "bottom" but it'll now be covering about 1/2 the graphic instead of just a third because it's still being pushed down by 8px.
What I'd like is if the position is bottom, then the margin-top is 8px, but if the position is top, the the margin-bottom is 8px.
Thanks for any help you can provide!
Billy McCafferty
Would this one help you?
http://dojo.telerik.com/amoZE/5
var tooltip = $("#demo").kendoTooltip({
filter: "a",
show: function (e) {
var position = e.sender.options.position;
if (position == "bottom") {
e.sender.popup.element.css("margin-top", "10px");
} else if(position == "top") {
e.sender.popup.element.css("margin-bottom", "10px");
}
}
}).data("kendoTooltip");
Thank you for your answer, jarno-lahtinen. It was very helpful!
Two problems came up with it and I would like to document the solutions here:
1. Property Error in Typescript
I am using TS and it gave me the following error:
"Property popup does not exist on type Tooltip" for e.sender.popup. I am not sure if this is due to a newer version of Kendo, or of missing type definitions.
Solution:
you can use this.popup instead.
2. Not working for position: "top"
Unfortunately, the "margin-bottom" has absolutely no effect because the popup is positioned "absolute" using top/left.
Solution:
this.popup.element.css("margin-top", "-10px");
This will shift the popup upwards by 10 pixels
I’m using Qt Creator. In my GUI I use a tab widget. This widget should have the same grey background color as the main window (picture A). I accomplished this by editing the Style Sheet in Qt Designer with:
background-colour: rgb(240, 240, 240);
But now I have two new problems I can’t solve:
The buttons (--> Send) are not rounded anymore.
The edit boxes’ background color has changed to grey, too.
Befor I changed the Style Sheet the GUI looked like in Picture B.
I also tried
QPalette pal = m_pUi->tabWidget->palette();
pal.setColor(m_pUi->tabWidget->backgroundRole(), Qt::blue);
m_pUi->tabWidget->setPalette(pal);
but this only changes the color behind the tabs, not the entire color of the whole "tab-window-surface".
Do I have to make additional style descriptions or is there an more simple solution?
Picture A - with Style Sheet
Picture B - without Style Sheet
I had the same problem and I discovered that you need to set this attribute to each one of your tabs:
ui->tab->setAutoFillBackground(true);
I'm not sure, but I think that also is necessary set that attribute to the QTabWidget as such.
I hope this help.
The "things" you want to access are called QTabBars. Keeping that in mind you can write a stylesheet like this:
QTabBar::tab
{
background: #48555E;
color: white;
border-color: #48555E;
}
QTabBar::tab:selected,
QTabBar::tab:hover
{
border-top-color: #1D2A32;
border-color: #40494E;
color: black;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #C1D8E8, stop: 1 #F0F5F8);
}
Also you might find this question and this official documentation insightful.