Widget for a foldable container in qml - widget

What qml widget should I use to create a foldable container? I can't find it.
Example (from Qt Creator):

There is no out of the box widget in QML for that but it should be fairly easy to create it yourself. This is just a primitive example to show how easy it could be to do it but a proper reusable control might be implementend similar like https://doc.qt.io/qt-5/qml-qtquick-controls2-tabbar.html:
import QtQuick 2.11
Column {
width: 600
height: 600
Rectangle {
width: parent.width
height: 50
color: "darkgrey"
MouseArea {
anchors.fill: parent
onClicked: container.height = container.height ? 0 : 500
}
}
Rectangle {
id: container
width: parent.width
height: 500
color: "grey"
}
}

Related

Increase the height of Filter List AG Grid Set Filter

Currently I am using Ag Grid v27.3.0, and contents inside filter list in Set Filter not being displayed correctly as shown in the below image. Data is not getting wrapped correctly.
Below is what i have tried, but of no use.
Am i missing anything here?
:host ::ng-deep .ag-set-filter-item
{
height: max-content;
}
It cannot be dynamic but you can set the height with the following config.
{ field: 'athlete', filter: true, filterParams: {
cellHeight: 35
} },
https://plnkr.co/edit/OOIbFw17EMxJWY72?open=app%2Fapp.component.ts

Angular: Changing font-size using css variables is applying but not reflecting in browser for certain fields

I am using CSS variables for a feature where the user has an option to change the font-size to small, medium or large. So for most of the fields, it's working as expected. But for certain fields, the value is applied but not reflected
:host-context(.mediumFont) {
--fontSize: 11px;
}
:host-context(.largeFont) {
--fontSize: 12px;
}
:host-context(.smallFont) {
--fontSize: 10px;
}
refClassArray: RefClassInterface[] = [
{ class: 'font-small', refClass: 'smallFont' },
{ class: 'font-medium', refClass: 'mediumFont' },
{ class: 'font-large', refClass: 'largeFont' },
];
defaultFontSize = 'mediumFont';
changeFontSize(selector: string) {
this.defaultFontSize = selector;
let docBody = document.body;
console.log(document.getElementById(selector));
docBody.classList.add(selector);
this.refClassArray.forEach((refClass: RefClassInterface) => {
if (selector !== refClass.refClass) {
docBody.classList.remove(refClass.refClass);
document.querySelector('#' + refClass.refClass).setAttribute('style', 'font-weight: normal;' + 'pointer-events: auto;');
} else {
document.querySelector('#' + refClass.refClass).setAttribute('style', 'font-weight:' + 'bold;' + 'pointer-events: none;');
}
});
this.ieStyles.iEfont(selector);
}
Above is the logic I am using.
The first pic is from the element which is working fine. When I hover over the --font-size, 11px is reflected. The second one is the one where it's not working as expected and when I hover over the --font-size nothing is appearing. And both these elements are inside <body>
You should not be modifying your html code via direct access. This can open leave your application vulnerable to XSS Attacks for instance.
Instead, the Angular Team recomends the use of the Renderer2.
Taking your code and modifying it to use it, would lead to the following:
refClassArray: RefClassInterface[] = [
{ class: 'font-small', refClass: 'smallFont' },
{ class: 'font-medium', refClass: 'mediumFont' },
{ class: 'font-large', refClass: 'largeFont' },
];
defaultFontSize = 'mediumFont';
changeFontSize(selector: string, indexOfClassToAdd: number) {
this.defaultFontSize = selector;
const el: Element = document.getElementById(selector));
// Iterate each class in the list to remove it.
this.refClassArray.forEach((refClass: RefClassInterface) => {
// Remove the class from the specific element only if its present.
if (el.classList.contains(refClass.refClass) {
this.renderer2.removeClass(el, refClass.refClass);
};
});
this.renderer2.addClass(el, refClassArray[indexOfClassToAdd].refClass);
};
This would imply that you are aware of what is the class to be applied (and it being present in the style.scss or and the appropriate scss file).
Kind regards.
Out of curiosity, why are you doing it this way rather than simply using a class with the desired text size?
Either way, it looks like your value is not being applied because your selector is not specific enough.
To correct for this, you could make an artificially specific selector with something like this:
html > body * { // rules }
Why not use ngClass?
Define three classes
.font-small{
fontSize: 10px
}
.font-medium{
fontSize: 11px
}
.font-large{
fontSize: 12px
}
Bind something to the user select, like userChoice: SizeEnum or something
Then, on your data element, use ngClass to bind
ngClass = "{
'font-small': userChoice === sizeEnum.small,
'font-medium': userChoice === sizeEnum.medium,
'font-large': userChoice === sizeEnum.large
}"
The issue was resolved by moving
:host-context(.mediumFont) {
--fontSize: 11px;
}
:host-context(.largeFont) {
--fontSize: 12px;
}
:host-context(.smallFont) {
--fontSize: 10px;
}
from app.component.scss to styles.scss. Because the pop-ups are not a part of app.compontnet.html they render outside it.

Hover over header of a tableView columns

I have a simple TableView with 4 TableViewColumns, I'm not usually working with qml, so I'm not really sure how to work properly inside this code.
What I want is that I need a mouse-over the TableView headers (column names). I checked all over and did not found any of a certain simple solution to my problem.
I have tried to use a tool-tip inside the TableVIewColumn but it never shows up, and I have seen that Mouse Area is not supported inside the TableViewColumn. Maybe the solution is simple but I am not aware of it for
the moment.
Rectangle {
width: parent.width
height: parent.height
TableView {
id: table
width: parent.width
height: parent.height
headerVisible: true
TableViewColumn {
id: time
role: "t-stamp"
title: "Time"
width: 60
}
TableViewColumn {
id: d
role: "id"
title: "SignId"
width: 40
}
TableViewColumn {
id: sid
role: "s-id"
title: "StratId"
width: 50
}
TableViewColumn {
id: stratname
role: "strat_name"
title: "StratName"
width: 200
}
Connections{
target: MessageTabelModel
onUpdateView:{
table.resizeColumnsToContents()
}
}
model: MessageTabelModel
}
}
TableView has a headerDelegate property that contains mouse information:
In the header delegate you have access to the following special
properties:
styleData.value - the value or text for this item
styleData.column -
the index of the column
styleData.pressed - true when the column is
being pressed
styleData.containsMouse - true when the column is under
the mouse
styleData.textAlignment - the horizontal text alignment of
the column (since QtQuickControls 1.1)
So you can use styleData.containsMouse for your needs, for example with a simple basic text:
headerDelegate: Text {
color: styleData.containsMouse ? "red" : "black"
text: styleData.value
// ...
}
Or if you want more customization:
headerDelegate: Rectangle {
height: 20
implicitWidth: headerText.paintedWidth
border.color: "black"
// ...
Text {
id: headerText
color: styleData.containsMouse ? "red" : "black"
text: styleData.value
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
}

ExtJs: Draggable element without Region

I want to create a GoogleMap like draggable div (as in this example http://tech.pro/tutorial/790/javascr...in-a-container).
But with ExtJs I did not find a way to achieve this without get rid of the Region...
I have a container which fit the screen and I have a huge div inside it (more than 10 000 px) which is centered (called it "area").
When I create an Ext.dd.DD class with this "area" element as a target, and start to drag... the DragDrop fonctionnality doesn't work as the div is stuck in the top-left corner.
Any idea on how to achieve this?
(Obviously, I don't want scoll, but drag and drop scroll).
Thanks in advance,
PsychoKrameur
PS: I'm using ExtJs 5.1
With ExtJS 5.1 you can use the TouchScroller, but be careful the class is private. That means it can change in further releases.
Example: https://fiddle.sencha.com/#fiddle/lmn
document.addEventListener("dragstart", function(e) {
e.preventDefault(); //This for the image otherwise it will dragged in IE
});
var panel = Ext.create("Ext.Panel", {
style: {
cursor: "move"
},
width: 400,
height: 400,
items: [{
xtype: "image",
width: 1019,
height: 1019,
src: "http://tech.pro/_sotc/sites/default/files/202/images/duck.jpg"
}],
renderTo: Ext.getBody()
});
Ext.defer(function() {
var childSize = panel.items.first().getSize();
var size = panel.getSize();
var scroller = Ext.scroll.TouchScroller.create({
element: panel.getOverflowEl()
});
scroller.scrollTo(size.width / 2 - childSize.width / 2, size.height / 2 - childSize.height / 2); //center the image
}, 1);

How to clip children in qml?

I have webView element that display google maps page. I need to show only map, without search input and other content. I have no idea except something like this:
Rectangle {
x: 0
y: 51
height: 549
//something like android clipChildren property
WebView {
id: mapView
x:0
y: -51
width: 800
height: 600
url: ""
onUrlChanged: {
mapView.reload()
}
}
}
but I don't know property that can do it.
Maybe use the clip: true; property which is present on every item in QtQuick ?