Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTextEdit->ensureCursorVisible() with QScrollArea
Forum Updated to NodeBB v4.3 + New Features

QTextEdit->ensureCursorVisible() with QScrollArea

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tux1124
    wrote on last edited by
    #1

    Hi,

    In my program, I have a QWidget that contains a QScrollArea which itself contains two QTextEdit.
    I just want the QTextCursor remains visible, so the user sees what he's typing.
    I know there is a method "ensureCursorVisible()" in QTextEdit but, strangely, it does not work with a QScrollArea.
    I'm using this code for the moment:
    @layout_vertical = new QVBoxLayout;
    QTextEdit *textEdit = new QTextEdit;
    scrollArea = new QScrollArea;
    scrollArea->setAlignment(Qt::AlignHCenter);
    widget = new QWidget;
    layout_vertical->addWidget(document_onglet, 0, Qt::AlignHCenter);
    widget->setLayout(layout_vertical);
    MyQMdiSubWindow->setWidget(scrollArea);
    textEdit->setMaximumHeight(1500);
    textEdit->setMinimumHeight(1500);
    textEdit->setMinimumWidth(800);
    textEdit->setMaximumWidth(800);
    textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    textEdit->ensureCursorVisible();
    QTextEdit *o2 = new QTextEdit;
    o2->setMaximumHeight(1500);
    o2->setMinimumHeight(1500);
    o2->setMinimumWidth(800);
    o2->setMaximumWidth(800);
    layout_vertical->addWidget(o2, 0, Qt::AlignHCenter);
    scrollArea->setWidget(widget); @

    Everything is OK except except that the QScrollAreanot move when the cursor disappears "under the program."
    So, how can I force the cursor to remain visible?

    Thanks :D

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved