How can QTextEdit send a message to its owner?
-
@JonB
But where would I ideally make the call to connect?
If I put it right before the emit, I'll be calling connect repeatedly.
Also I am finding that windowHandle always returns NULL, no matter where I call it.
But the slot is in the main window.@clarify
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 theQTextEdit? 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.If you take the approach of having perhaps a subclassed
QTextEdithandle the required resizing itself per the links, without involving the outside world, that might avoid problems. -
@clarify
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 theQTextEdit? 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.If you take the approach of having perhaps a subclassed
QTextEdithandle the required resizing itself per the links, without involving the outside world, that might avoid problems.@JonB said in How can QTextEdit send a message to its owner?:
It doesn't feel like a main window responsibility to deal with resizing a text edit within some table.
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.
-
@JonB said in How can QTextEdit send a message to its owner?:
It doesn't feel like a main window responsibility to deal with resizing a text edit within some table.
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.
-
@JonB The QTextEdit is inside a table cell.
There's no way to get a pointer to the QTextEdit from the window code.@clarify
Can you actually explain what you have, we don't know? You have mentioned a main window, a text edit, and a "table".Do you mean you have perhaps a
QGridLayout? Do you mean you have aQTableView/QTableWidget? Have you made that editable and you are talking about the editor it presents? Or maybe you have usedsetCellWidget()? It's a lot easier if you say than we have to guess.And/or why would the stackoverflow approach require the outside world to be connected to a signal or need to access the text edit?
-
@clarify
Can you actually explain what you have, we don't know? You have mentioned a main window, a text edit, and a "table".Do you mean you have perhaps a
QGridLayout? Do you mean you have aQTableView/QTableWidget? Have you made that editable and you are talking about the editor it presents? Or maybe you have usedsetCellWidget()? It's a lot easier if you say than we have to guess.And/or why would the stackoverflow approach require the outside world to be connected to a signal or need to access the text edit?
@JonB Did you read all of the discussion?
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.
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.
-
@JonB Did you read all of the discussion?
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.
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.
@clarify said in How can QTextEdit send a message to its owner?:
I was once told I have to create the QTextEdit inside a delegate
And that is indeed exactly what you should do. Create your own
QStyledItemDelegate-derived class to use your ownQTextEdit-derived class forcreateEditor()and implement as per the stackoverflow thread.QStyledItemDeletealso has its ownsizeHint(). Set the delegate on the table widget cell/row/column. -
@clarify said in How can QTextEdit send a message to its owner?:
I was once told I have to create the QTextEdit inside a delegate
And that is indeed exactly what you should do. Create your own
QStyledItemDelegate-derived class to use your ownQTextEdit-derived class forcreateEditor()and implement as per the stackoverflow thread.QStyledItemDeletealso has its ownsizeHint(). Set the delegate on the table widget cell/row/column. -
@JonB But if I continue with that, how will I make the call to connect?
Inside the delegate routine createEditor, I won't have a pointer to the window.@clarify
To what window, and why?
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 stackoverflow approach. Over to you now. -
@clarify
To what window, and why?
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 stackoverflow approach. Over to you now.@JonB
There has to be some piece of code somewhere that manages the table row heights.
The table itself is unable to handle that.
Therefore that code is in its parent, the window.
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.
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.