<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How can QTextEdit send a message to its owner?]]></title><description><![CDATA[<p dir="auto">I have a QTextEdit that needs to inform its containing view and/or window that something has happened.</p>
<p dir="auto">Is there a good way to do that?<br />
Thanks.</p>
]]></description><link>https://forum.qt.io/topic/144097/how-can-qtextedit-send-a-message-to-its-owner</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Apr 2026 04:49:38 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/144097.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 03 Apr 2023 17:04:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 20:23:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a><br />
There has to be some piece of code somewhere that manages the table row heights.<br />
The table itself is unable to handle that.<br />
Therefore that code is in its parent, the window.<br />
To me this is very simple. The table is unable to resize a row automatically when the editor in a cell needs to grow vertically.<br />
The SO code was in Python and some of the methods it showed didn't apply to C++, for instance there is no setHeightMin method.</p>
]]></description><link>https://forum.qt.io/post/753499</link><guid isPermaLink="true">https://forum.qt.io/post/753499</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 03 Apr 2023 20:23:12 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 20:15:52 GMT]]></title><description><![CDATA[<p dir="auto">@clarify<br />
To <em>what</em> window, and <em>why</em>?<br />
I have explained too many times.  There is no need to connect the outside world/main window to the text edit to implement what you want.  I have asked several times if you have looked at and tried the <strong>stackoverflow</strong> approach.  Over to you now.</p>
]]></description><link>https://forum.qt.io/post/753496</link><guid isPermaLink="true">https://forum.qt.io/post/753496</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Mon, 03 Apr 2023 20:15:52 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 20:13:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> But if I continue with that, how will I make the call to connect?<br />
Inside the delegate routine createEditor, I won't have a pointer to the window.</p>
]]></description><link>https://forum.qt.io/post/753494</link><guid isPermaLink="true">https://forum.qt.io/post/753494</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 03 Apr 2023 20:13:04 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 20:09:17 GMT]]></title><description><![CDATA[<p dir="auto">@clarify said in <a href="/post/753492">How can QTextEdit send a message to its owner?</a>:</p>
<blockquote>
<p dir="auto">I was once told I have to create the QTextEdit inside a delegate</p>
</blockquote>
<p dir="auto">And that is indeed exactly what you should do.  Create your own <code>QStyledItemDelegate</code>-derived class to use your own <code>QTextEdit</code>-derived class for <code>createEditor()</code> and implement as per the <strong>stackoverflow</strong> thread.  <code>QStyledItemDelete</code> also has its own <code>sizeHint()</code>.  Set the delegate on the table widget cell/row/column.</p>
]]></description><link>https://forum.qt.io/post/753493</link><guid isPermaLink="true">https://forum.qt.io/post/753493</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Mon, 03 Apr 2023 20:09:17 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 20:00:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> Did you read all of the discussion?</p>
<p dir="auto">I have a table (QTableWidget) which contains editable cells. When the user types too much, the cell (or row) height does not resize, no matter how I configure things.</p>
<p dir="auto">I don't know about setCellWidget. I was once told I have to create the QTextEdit inside a delegate so that is where it's created. It seemed like a terrible way to do things, but it was described as a Qt-specific approach.</p>
]]></description><link>https://forum.qt.io/post/753492</link><guid isPermaLink="true">https://forum.qt.io/post/753492</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 03 Apr 2023 20:00:24 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 19:51:40 GMT]]></title><description><![CDATA[<p dir="auto">@clarify<br />
Can you actually explain what you have, we don't know?  You have mentioned a main window, a text edit, and a "table".</p>
<p dir="auto">Do you mean you have perhaps a <code>QGridLayout</code>?  Do you mean you have a <code>QTableView</code>/<code>QTableWidget</code>?  Have you made that editable and you are talking about the editor it presents?  Or maybe you have used <code>setCellWidget()</code>?  It's a lot easier if you say than we have to guess.</p>
<p dir="auto">And/or why would the <strong>stackoverflow</strong> approach require the outside world to be connected to a signal or need to access the text edit?</p>
]]></description><link>https://forum.qt.io/post/753490</link><guid isPermaLink="true">https://forum.qt.io/post/753490</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Mon, 03 Apr 2023 19:51:40 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 19:45:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> The QTextEdit is inside a table cell.<br />
There's no way to get a pointer to the QTextEdit from the window code.</p>
]]></description><link>https://forum.qt.io/post/753489</link><guid isPermaLink="true">https://forum.qt.io/post/753489</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 03 Apr 2023 19:45:02 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 19:41:26 GMT]]></title><description><![CDATA[<p dir="auto">@clarify<br />
What "table"?<br />
Did you look at the code from the <strong>stackoverflow</strong> link?  Did you try it?</p>
]]></description><link>https://forum.qt.io/post/753488</link><guid isPermaLink="true">https://forum.qt.io/post/753488</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Mon, 03 Apr 2023 19:41:26 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 19:33:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> said in <a href="/post/753484">How can QTextEdit send a message to its owner?</a>:</p>
<blockquote>
<p dir="auto">It doesn't feel like a main window responsibility to deal with resizing a text edit within some table.</p>
</blockquote>
<p dir="auto">I agree about that, but there seems to be no way to configure the table to let the cell that's being edited cause the row to be grown vertically.</p>
]]></description><link>https://forum.qt.io/post/753485</link><guid isPermaLink="true">https://forum.qt.io/post/753485</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 03 Apr 2023 19:33:38 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 19:30:05 GMT]]></title><description><![CDATA[<p dir="auto">@clarify<br />
If you need to connect a signal you do it once, from somewhere which can see (i.e. has variables for) both the signalling and slot objects.  If the slot is in the main window you may need to it there.  Does it have access to the <code>QTextEdit</code>?  Whether the slot needs to be in the main window I cannot say.  It doesn't feel like a main window responsibility to deal with resizing a text edit within some table.</p>
<p dir="auto">If you take the approach of having perhaps a subclassed <code>QTextEdit</code> handle the required resizing itself per the links, without involving the outside world, that might avoid problems.</p>
]]></description><link>https://forum.qt.io/post/753484</link><guid isPermaLink="true">https://forum.qt.io/post/753484</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Mon, 03 Apr 2023 19:30:05 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 19:20:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a><br />
But where would I ideally make the call to connect?<br />
If I put it right before the emit, I'll be calling connect repeatedly.<br />
Also I am finding that windowHandle always returns NULL, no matter where I call it.<br />
But the slot is in the main window.</p>
]]></description><link>https://forum.qt.io/post/753482</link><guid isPermaLink="true">https://forum.qt.io/post/753482</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 03 Apr 2023 19:20:06 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 19:00:23 GMT]]></title><description><![CDATA[<p dir="auto">@clarify<br />
That is quite correct, so have it emit the signal.  Something still has to connect to the <code>QTextEdit</code> instance's signal.<br />
Or, depending on what you want to do, can you handle the behaviour you want inside a <code>QTextEdit</code> subclass maybe, without needing the outside world to be signalled?<br />
It might be that reimplementing <code>QTextEdit::sizeHint()</code> to expand on change is enough, don't know when that gets called though.</p>
<p dir="auto">I wonder if <a href="https://stackoverflow.com/questions/11851020/a-qwidget-like-qtextedit-that-wraps-its-height-automatically-to-its-contents" target="_blank" rel="noopener noreferrer nofollow ugc">A QWidget like QTextEdit that wraps its height automatically to its contents?</a> does just what you are looking for?<br />
Or there is <a href="https://github.com/cameel/auto-resizing-text-edit/blob/master/auto_resizing_text_edit/auto_resizing_text_edit.py" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/cameel/auto-resizing-text-edit/blob/master/auto_resizing_text_edit/auto_resizing_text_edit.py</a> ?</p>
]]></description><link>https://forum.qt.io/post/753479</link><guid isPermaLink="true">https://forum.qt.io/post/753479</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Mon, 03 Apr 2023 19:00:23 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 18:48:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a><br />
I want to detect when the user has entered more characters<br />
into the QTextEdit than will fit in it horizontally.<br />
At that point I will make it taller.<br />
Since the QTextEdit is the source of truth about whether the text fits,<br />
I want it to emit that signal, rather than have the container<br />
reach into it (somehow) and determine whether the text fits.</p>
]]></description><link>https://forum.qt.io/post/753478</link><guid isPermaLink="true">https://forum.qt.io/post/753478</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 03 Apr 2023 18:48:31 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 18:38:18 GMT]]></title><description><![CDATA[<p dir="auto">@clarify hi, what exactly do you want your view to react to ?<br />
Usually, the dataChanged signal of the model is used to notify the view that something has changed.</p>
]]></description><link>https://forum.qt.io/post/753475</link><guid isPermaLink="true">https://forum.qt.io/post/753475</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 03 Apr 2023 18:38:18 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 18:41:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> The QTextEdit is created by a delegate of the table.<br />
There's a method called createEditor in the delegate.<br />
So I tried to call connect from the QTextEdit constructor, but<br />
(updated:)  I find that the object I want to send the message to,<br />
which is the window, is NULL.</p>
]]></description><link>https://forum.qt.io/post/753474</link><guid isPermaLink="true">https://forum.qt.io/post/753474</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 03 Apr 2023 18:41:09 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Wed, 05 Apr 2023 08:26:28 GMT]]></title><description><![CDATA[<p dir="auto">@clarify<br />
No, if you want to connect to a <code>QTextEdit</code> signal you need its instance to do the <code>connect()</code>.<br />
Table cells are not relevant.  Table cells cannot emit signals.<br />
You might do the connect as the <code>QTextEdit</code> is created/passed to <code>setCellWidget()</code>, or you can find an existing one via <code>cellWidget()</code> calls if required.<br />
Don't think of widgets sending messages to their owners, think of owners listening for any signals child widgets might send.</p>
]]></description><link>https://forum.qt.io/post/753472</link><guid isPermaLink="true">https://forum.qt.io/post/753472</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 05 Apr 2023 08:26:28 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 18:14:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/christian-ehrlicher">@<bdi>Christian-Ehrlicher</bdi></a><br />
I have the QTextEdit in a table cell.<br />
If it's the QTextEdit that is sending the signal, but it is internal to the table cell which is within the table, I wonder how I will perform the "connect".<br />
Can I say connect(NULL, ...) to specify an anonymous emitter?</p>
]]></description><link>https://forum.qt.io/post/753471</link><guid isPermaLink="true">https://forum.qt.io/post/753471</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 03 Apr 2023 18:14:22 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 17:13:55 GMT]]></title><description><![CDATA[<p dir="auto">@clarify I think you mean signals, <a href="https://doc.qt.io/qt-6/qtextedit.html#signals" target="_blank" rel="noopener noreferrer nofollow ugc">here</a> you can find signals for <code>QTextEdit</code> to get notified about different changes that happen to it.</p>
]]></description><link>https://forum.qt.io/post/753454</link><guid isPermaLink="true">https://forum.qt.io/post/753454</guid><dc:creator><![CDATA[CPPUIX]]></dc:creator><pubDate>Mon, 03 Apr 2023 17:13:55 GMT</pubDate></item><item><title><![CDATA[Reply to How can QTextEdit send a message to its owner? on Mon, 03 Apr 2023 17:05:23 GMT]]></title><description><![CDATA[<p dir="auto">@clarify said in <a href="/post/753450">How can QTextEdit send a message to its owner?</a>:</p>
<blockquote>
<p dir="auto">Is there a good way to do that?</p>
</blockquote>
<p dir="auto">I would say - <a href="https://doc.qt.io/qt-6/signalsandslots.html" target="_blank" rel="noopener noreferrer nofollow ugc">Signals and Slots</a></p>
]]></description><link>https://forum.qt.io/post/753451</link><guid isPermaLink="true">https://forum.qt.io/post/753451</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Mon, 03 Apr 2023 17:05:23 GMT</pubDate></item></channel></rss>