Unsolved QTextEdit
-
Can somebody provide me the code or tutorial for making a drag and droppable QtextEdit in QT, which can also be resized manually by the user according to his/her need. I searched it many times but couldn't find it.
-
Hi
What you mean by a
" a drag and droppable QtextEdit " ?If you mean one, that accept drops ( and maybe drags)
http://doc.qt.io/qt-5/qtwidgets-draganddrop-draggabletext-example.html
You must subclass the textEdit and handle the dragX functions
protected:
void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE; -
Resizing a widget is usually not performed through direct user interaction with that widget but through a layout into which the widget is embedded. I guess you QTextEdit is part of some dialog or window. which uses some layout, e.g. a QVBoxLayout. If you resize the Window, the layout tells your QTextEdit to resize accordingly. I would recommend this standard approach since manual handling of resizing is quite cumbersome and error prone.
-
@mrjj I mean that I am creating a side palette like paint and I want to drag and drop a rectangle from that palette to my workspace and when user place it where he wants, then some value needs to be entered in that which I will process further.
-
@sanjay1155
Ok
Well first read about how it works
http://doc.qt.io/qt-5/dnd.htmlThis one drags from list to area
http://doc.qt.io/qt-5/qtwidgets-draganddrop-puzzle-example.htmlSo you can see how startDrag etc is used.