I would like to modify the KDE widget User Switcher to let the user decide the size of the icons to be shown in the fullRepresentation view. The user set a value in a combobox in the settings, and the view should automatically update.
To achieve this, I've added the code iconSize: getIconSize(combo_currentIndex) in each ListDelegate instance. Here, getIconSize is a simple javascript function that returns the specified value from units.iconSizes.
Then, I tried two approaches:
Approach 1: In ListDelegate.qml I have created the property alias iconSize: icon.Layout.minimumWidth. It doesn't work, the widget load and shout out this error: ListDelegate.qml:41:30: Invalid alias target location: Layout.
Approach 2: In ListDelegate.qml I have created the property int iconSize: units.iconSize.medium (I chose medium because that's the default option in the user settings). Then I changed the Layouts properties of the PlasmaCore.IconItem as follows:
Layout.minimumWidth: iconSize
Layout.maximumWidth: iconSize
Layout.minimumHeight: iconSize
Layout.maximumHeight: iconSize
At this point, the size of the icons changes accordingly to the user settings. But the ListDelegate item height remain fixed (as it were still using units.iconSize.medium), therefore the icons overlaps when the user chooses an icon size greater than medium.
What can I do to solve this problem?
After reading the docs, I have fully understand how Layout works.
The solution of Approach 2 is quite simple. I also needed to set the correct values to the Layout properties minimumHeight, maximumHeight and preferredHeight of the parent element (which is the RowLayout row):
Layout.minimumHeight: units.iconSizes.tiny
Layout.maximumHeight: units.iconSizes.enormous
Layout.preferredHeight: iconSize
The code should be self explanatory. In doing so, the parent RowLayout element is able to correctly change it's height to accomodate the icon.
Related
The Goal
I want to have a v-data-table that is editable and looks "nice".
The problem
Adding a v-text-field to make it editable also increases the row-height to a very eye unpleasing level
Original view:
With v-text-field inputs
The quesion
How can I decrease the row height to resemble the one without v-text-fields.
As a Bonus
Because I am quite new to this whole Front-End-Development-Kind-Of-Thing, how would I go about it identifying what is causing this "height issue"?
PS: I've tried to add a JSFiddle but I cant even seem to be unable to figure out how to display the v-data-table correctly...
The basic draft can be found here
Is it necessary for your table to be editable within the columns? How do you decide when to pass data back via request to your Backend? After the user left a field?
If it is not necessary to have the edit option within the table, I would just use the action buttons you already have in your table to trigger a modal in which you can edit the fields. This also allows you to have proper form control before a user can submit a request. There is also a Vuetify Codepen with an example how to do this Codepen
If it is necessary you should implement the v-data-table as v-data-iterator which is essentially the same functionality-wise, but allows for complete control over the look. https://vuetifyjs.com/en/components/data-iterators/
As to how to identify the problem with the v-text-field height you have to use your browser dev tools. You would then realise that the input has default paddings and margins but also a whole lot under the hood. It e.g. allocates space for error messages to pop up and for a label to go above the field.
And how to fix your JSfiddle you can read in the getting started section of the vuetify documentation under CDN https://vuetifyjs.com/en/getting-started/installation/#usage-with-cdn.
you can use the "dense" property for Lower height of v-data-table inputs
https://vuetifyjs.com/en/components/data-tables/#dense
I'm working with PyQt and I was wondering if there is any way to set a grid layout in a window so that, for example, one button's geometry wouldn't be affected by the configuration of the layout - because I'm trying to have my button in a square shape and, with the grid layout, it always becomes a long rectangle.
Also, I have multiple rows and columns, and to edit each minimum size would be horrifying. So, is there is any way to establish the geometry of a widget in a grid layout?
UPDATE: my grid
self.Grid = QtGui.QGridLayout()
self.Grid.addWidget(self.Button1,0,0)
self.Grid.addWidget(self.Box1,2,1)
self.Grid.addWidget(self.Box2,2,3)
self.Grid.addWidget(self.Button2,0,4,Qt.AlignRight)
self.Grid.setRowMinimumHeight(1,50)
self.Grid.setRowMinimumHeight(1,50)
self.Grid.setRowMinimumHeight(3,250)
self.Grid.setColumnMinimumWidth(0,100)
self.Grid.setColumnMinimumWidth(2,50)
self.Grid.setColumnMinimumWidth(4,100)
self.setLayout(self.Grid)
Given the example code in your question, just add something like the following:
self.Button1.setMinimumSize(50, 50)
self.Button1.setMaximumSize(50, 50)
or:
self.Button1.setFixedSize(50, 50)
Some of the list columns I render have the option for the user to enter a mass of data. If they do it can cause the view of the screen to be skewed as there is too much content in one column and the rest of the columns aren't visible on the screen without scrolling.
I am seeking to change the width of list columns, similar to the solution that is described here: http://aanuwizard.com/2010/08/01/sharepoint-2010-how-to-change-width-of-list-column/ but I didn't want to use sharepoint designer. Ideally I could just set a max width for everything, so it wouldn't ruin the views if a lot of content was input.
I was hoping to do it with CSS, as I can inject css into my SP pages. Is it possible? how could I do it?
This is not a very nice solution, but if you don't want to use SharePoint Designer it might be what you need:
One thing you could do if you don't want to use the SharePoint Designer is to add a Content Editor WebPart containing a javascript that applies the CSS for you.
You would either add a stylesheet in your content editor webpart and apply your stilesheet to the desired element, or you can also try to change the .style property of your element directly. As seen here:
function changeElement(id) {
var el = document.getElementById(id);
el.style.color = "red";
el.style.fontSize = "15px";
el.style.backgroundColor = "#FFFFFF";
}
Some more information on how to do this can be found here:
http://www.w3.org/wiki/Dynamic_style_-_manipulating_CSS_with_JavaScript
I am building a Flex 4 application which uses a <s:Scroller> component to vertically scroll overflown content. Let me explain what happens before I ask my question:
The body of the page is loaded from a database
Once the information has loaded, the "body" of the application (in this case the list of items you see below) is constructed
Once the list is constructed, the entire encapsulating component is transitioned into view using TweenMax, like so:
myComponent.visible = true;
TweenMax.to(myComponent, 1, {
alpha : 1,
y -= 20 //Slides the component up 20px from its original location
});
Below is the result. Notice how the scrollbar is scrolled the whole way down, but you can see the tips of a few white letters that were cut off at the very bottom.
Using my custom menu, I can navigate away from the page, and come back to it, and Flex will correctly recalculate the range of the scroller so I can scroll down and see all of the desired content. This issue only happens if the initial URL that the user enters is a longer page like this one.
Any ideas on how I can force Flex to recalculate the range of the scroller?
Thank you for your time.
Ok, after many hours of researching, piecing together, and trial and error here is what I came up with.
What I was doing wrong:
When I first posted this question, the "component" that I had mentioned was already added as a child element of the <s:Scroller>, but collapsed and hidden away, like this:
<comp:MyComp alpha="0" height="0" visible="false"/>
When the data would be loaded and the component's visual appearance would be restored and transitioned into place, like this:
myComp.visible = true;
myComp.height = NaN;
myComp.invalidateSize();
myComp.height = myComp.measuredHeight;
TweenMax.to(myComp, 1, {
alpha : 1,
y -= 20 //Slides the component up 20px from its original location
});
This method of approach didn't force the <s:Scroller> to recalculate its proper size until later, sometimes not until myComp was transitioned away and another component was transitioned into place using the same method. Even then, the size of the scroller would fit the size of the previous component, not the one that is currently displaying.
Now, what I am doing correctly:
My research showed me that anytime the addElement() method is called, either directly within the <s:Scroller> itself or by any of its children, the scroller's measure() method is called, and properly re-sizes the scroller.
Instead of placing the components inside of the scroller and simply hiding them until I need them, I dynamically created them in ActionScript, set their properties, and added and removed them as needed using the addElement() and removeElement() methods respectively. Now, as old elements are transitioned away and new ones take their place, the scroller re-sizes itself correctly.
There was one final problem that I was faced with. If the very first page the user was viewing (i.e. there was no previous component that was transitioned away and destroyed) required a scroller, it wouldn't show up.
I corrected this final issue by adding an event listener that listened for when the new component had finished transitioning into place. Inside of the event handler, I explicitly set the height of the component using this code:
newComp.height = NaN;
newComp.invalidateSize();
newComp.height = newComp.measuredHeight;
Now that the component has an explicit height, the scroller now appears, even if it is the first page.
The scroller now works as expected in all cases, and does not cut off any content or disappear when it shouldn't.
I hope that it is helpful to someone.
How do I overlay widgets in Qt?
I want to create some widgets and place them out-of-layout, but rather tweak their size and position when some other widget's geometry is changed.
Something like the buttons on the screenshot:
You just need to create your QPushButton (or any QWidget), indicate its parent QWidget and then display it.
Don't add it to the parent layout else you will not be able to move it as you want.
Don't forget to indicate its parent else it will be displayed as independant QWidget.
In these conditions your QPushButton will be considered as child of the QWidget but not member of the parent's layout. So it will be a "floating" child and you must manage it's behaviour when resizing parent's QWidget.
If you want a unified behaviour for all overlay buttons, you should subclass QLayout and redefine members bahaviour.
If they're child of a widget without a layout, you should be able to move them around as you please, I think.
I needed a widget like this for a project I'm working on, so I took Patrice advice and wrote this code (Python) PyQt4 Widget Overlay