nodegui / react-nodegui

Build performant, native and cross-platform desktop applications with native React + powerful CSS like styling.🚀
https://react.nodegui.org
MIT License
6.18k stars 171 forks source link

How to handle auto scroll on control QPlainTextEdit #103

Open leovo2708 opened 4 years ago

leovo2708 commented 4 years ago

I append text to the control QPlainTextEdit after interval, please help me how to scroll to the bottom,

I can't find any APIs: https://docs.nodegui.org/docs/api/generated/classes/qplaintextedit

Thanks

a7ul commented 4 years ago

Hi @leovo2708 I couldnt understand what you meant here. Could you post the code snippet ?

Also, it would be awesome if you can open the issue as per the issue template.

leovo2708 commented 4 years ago

@master-atul I want after appending text to this control and scrollbar appears, I want to scroll to bottom by programming. Thanks.

Duxy1996 commented 4 years ago

I'm having the same issue. I don't know how to hold the scroll bar in the bottom like an installer wizard.

poky1084 commented 2 years ago

NodeGUI version: "@nodegui/nodegui": 0.36.0

I have the same issue with QTextEdit.

Here is some code:

const showLog = new QTextEdit();
showLog.setReadOnly(true);
showLog.setProperty('textInteractionFlags', 1);
showLog.setInlineStyle('flex: 2;');

**in a loop:**
showLog.setText(showLog.text() + "1234<br>");
const position = new QCursor();
position.pos(0, 9999999);
showLog.setCursor(position);

I tried to set the scrollbar position by setting setCursor(), to scroll to the end of Qtextedit, but without success. i made a new QCursor and changed its pos y=9999999 - to a high value - in hope that it will scroll to the end of the Qtextedit while its adding text with newlines to the textedit.

Any ideas? It maybe that while the Qtextedit is readonly it cant set cursor or scrollbar.. OR maybe i have to change the text adding in reverse direction like adding to the top of every line.

I read here about this issue: https://www.qtcentre.org/threads/5983-QTextEdit-auto-scroll

Is there a way to have it scroll down to the bottom of the page always when data is being inserted?