picklechips
picklechips

Reputation: 804

Qt set scroll area of a QPlainTextEdit to match that of anothers.

I for the life of me can't figure out how to do this.

I have two QPlainTextEdits, with word wrapping off.
I fill one using myTextEdit->document()->setPlainText(myText);
Now myTextEdit has a horizontal scroll bar. Now I want my other textEdit to be able to scroll the exact same amount as myTextEdit, despite how many words are in it. How can i set the width within the scroll area of my other text edit to match that of myTextEdit?

I want the document widths to be the same, but myTextEdit->document()->size() has been of no use. Can anyone help?

Upvotes: 2

Views: 902

Answers (2)

mvidelgauz
mvidelgauz

Reputation: 2214

Assuming you already have a function (SLOT?) called when first text edit is changed:

myOtherTextEdit->horizontalScrollBar()->setMaximum(myFirstTextEdit->horizontalScrollBar()->maximum());

Upvotes: 1

user2836797
user2836797

Reputation:

Have you tried using signal and slots to link the widget sizes with setFixedSize()?

Upvotes: 0

Related Questions