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

QTextEdit

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.3k Views
  • 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.
  • S Offline
    S Offline
    sanjay1155
    wrote on last edited by sanjay1155
    #1

    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.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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;

      S 1 Reply Last reply
      0
      • S Offline
        S Offline
        stryga42
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • mrjjM mrjj

          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;

          S Offline
          S Offline
          sanjay1155
          wrote on last edited by sanjay1155
          #4

          @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.

          mrjjM 1 Reply Last reply
          0
          • S sanjay1155

            @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.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #5

            @sanjay1155
            Ok
            Well first read about how it works
            http://doc.qt.io/qt-5/dnd.html

            This one drags from list to area
            http://doc.qt.io/qt-5/qtwidgets-draganddrop-puzzle-example.html

            So you can see how startDrag etc is used.

            1 Reply Last reply
            1

            • Login

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