Slick Grid how to add seek top & seek bottom scroll buttons? - grid

I'm using slick grid for my application, I need a seek top & seek bottom buttons, Example: if user clicks seek bottom user can directly go to bottom of the grid, vice-versa, I'm completely new to slick Grid,Thanks in advance.
Seek Top Seek Bottom
|<< >>|

At present, you can just grab the scroll bar 'visible' section and drag it to the bottom. Paging is something like what you want:
http://6pac.github.io/SlickGrid/examples/example4-model.html
However in the end, you can do what you want using grid.scrollRowIntoView().
'Seek Top' is scrolling to row 0, 'Seek Bottom' is scrolling to row (data.length - pagesize), or just (data.length - 1): the final row.

Related

React-beautiful-dnd: Prevent page from scrolling when draggable is being dragged near edge of page

I'm using react-beautiful-dnd in a project and when I'm dragging a draggable, the page auto scrolls if I drag it near the top, bottom or sides of the page. I could theoretically fix this problem by placing the drag and drop container in the middle of the page so that the user probably wouldn't trigger the auto scroll as the draggable wouldn't be dragged to the edges of the page, but I'd prefer not to alter the layout in that way. Is there any way to disable the auto scrolling?

Android : negative margins behave differently on different versions

I am writing an application where I need to move a view from top to bottom but only when user moves it downward. To move this view I have a button below the view to drag. So initially I place the view beyond top of the view i.e. with negative margin equals the height and only the drag button is visible at the top to user. I see that this works perfectly on Lollipop and view is just at the position where bottom of view matches the top of screen. When I try it on Kitkat and lower versions, the view goes more towards top than the edge of screen. I have this everything in a RelativeLayout.
To show that view is dragged downward I am manipulating bottomMargin and topMargin properties on view.
Has anyone came across similar problems? Thanks in advance.

QTextEdit: scroll down automatically only if the scrollbar is at the bottom

There's a QTextEdit that displays quite a lot of text. It is NOT editable. Suppose I want to read something around the beginning, scroll up, but then a new line is added and the scrollbar automatically goes to the bottom. I experience similar problems when using various programs (regardless of the language they were written in). How does one deal with this problem?
The behavior I want when a new line is added to the text:
if the scrollbar is at the bottom, scroll down automatically.
if the scrollbar is elsewhere, don't scroll
I suppose that
ensureCursorVisible()
is not the solution, since the QTextEdit is not editable, the user won't click inside it, and the position of the cursor is not the same as the position of the vertical scrollbar.
I would make Scroll bar position listener, which will remember position on scrolling (and also check is it at the bottom or not).
Then, when new line is added, check is it at bottom, if is scroll down, if is somewhere else then scroll back to that position.
Check this QScrollBar, you can grab it from QTextEdit via horizontalScrollBar() and verticalScrollBar().
More concrete, I would connect slot with signal from QScrollBar - valueChanged(int value) and play with values as it is described here.
It is not necessary to connect a scrollbar listener. Just query the scrollbar before appending text:
QScrollBar *scrollbar = textedit->verticalScrollBar();
bool scrollbarAtBottom = (scrollbar->value() >= (scrollbar->maximum() - 4));
int scrollbarPrevValue = scrollbar->value();
The "minus 4" hack in scrollbarAtBottom is necessary since ensureCursorVisible() does not scroll exactly to the bottom, but some fixed amount above. Check it with your font sizes.
Now you can insert the text:
textedit->moveCursor(QTextCursor::End);
// begin with newline if text is not empty
if (! textedit->document()->isEmpty())
textedit->insertHtml(QStringLiteral("<br>"));
textedit->insertHtml(QStringLiteral("My text here."))
After that operation, either scroll to the bottom, or fix the scrollbar such that it does not move at all:
if (scrollbarAtBottom)
textedit->ensureCursorVisible();
else
textedit->verticalScrollBar()->setValue(scrollbarPrevValue);

QT - Place Buttons on Bottom Right

I am trying to place a set of buttons so that they are anchored to the bottom right of the screen. My problem is that whenever I resize the screen, the buttons are not anchored to the bottom right, but stay in its current position.
I have placed two Push Buttons inside a Horizontal Layout. I then placed this layout inside a Grid Layout, which contains a Horizontal and Vertical Spacer. I have modified the Grid Layout layoutSize property to SetMaximumSize.
What am I doing incorrectly, so that I can get my buttons to be anchored to the bottom right?
You have almost everything just right here, but you probably overlooked something that is really easy to miss when you first start using Qt Designer.
Your grid layout is sitting inside your widget with a fixed size and position. It too needs to be managed by a layout. If you take a look at the Object Inspector on the top right (that contains your hierarchy) you will probably see your top level widget with a red icon. This indicates that it contains no layout. You have two options to fix this...
Have your existing grid layout placed into another main layout (like a vertical layout). You would simply right click on your top level widget in the Object Inspector -> Lay Out -> [Choose a main layout type].
Have your grid be the main layout. To do this you would need to remove the grid layout and have your child items arranged exactly how you have them in that picture. Then follow the previous option, right clicking on the top level widget (or the blank background) and choose Lay out -> Grid. This will pop your widgets into a Grid at a best visual fit (which you can then fix if needed), and your grid will be the top level layout.
That grid layout will make placing other widgets quite hard. Try this instead:
Add (from left to right) horizontal spacer and the two buttons.
Multiselect them all.
Select "Lay Out Horizontally" (Ctrl-H) from the Qt Designer's (or Qt Creator's) top toolbar (not from the widget box in the left!).
Add vertical spacer on top of the previous widgets.
Select the main window by clicking it (none of the added widgets are now selected).
Select "Lay Out Vertically" (Ctrl-L) from the top toolbar.
Done.
It seems that you're doing it correctly. Just forgot to apply a layout to your central widget, right? The Grid layout should be arranged in your central widget. The more convenient way is to remove grid layout widget and lay out the central widget in a grid ;-)

How to scale an widget in specified in qt

I have divided my main screen in 4 areas as border-layout as center,right,left and bottom. The right, left and bottom areas are small and contain only buttons. My center area has to display the different widgets and forms depending on the buttons pressed in right/left/bottom areas.
Can anybody suggest how I can design my forms or widgets so that when I show the widget in the center area, it will fit into the center area and all the items inside this will be scaled rationally.
Please refer to the attached image file for a better idea.
If my explanation is not clear please let me know I will try better.
Looks like you already have a decent start. If you only have icons, typically icons won't be able to expand much so you will want your left,bottom and right containers to be non-expanding.
The center container (most likely a QStackedWidget in your case) will be expanding both horizontally and vertically.
You will also need to add spacers at the bottom of left area and right area.
The bottom area can also use spacers on both sides.
In short
Bottom area: sizePolicy: Preferred/Minimum, maximumSize: inf/40
Left area: sizePolicy: Minimum/Preferred, maximumSize: 40/inf
Right area: sizePolicy: Minimum/Preferred, maximumSize: 40/inf
Center area: sizePolicy: Preferred/Preferred, maximumSize: inf/inf
Here is what you can do with drag and drop within QtDesigner
Here is what it looks like
Here is what it will look like expanded. Notice that although the main area is bigger, the buttons sides remain the same.

Resources