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. [SOLVED]How to delete an item from the treeview by droping an item to pushbutton or to an group box
QtWS25 Last Chance

[SOLVED]How to delete an item from the treeview by droping an item to pushbutton or to an group box

Scheduled Pinned Locked Moved General and Desktop
drag and droptreeview
54 Posts 4 Posters 22.1k 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.
  • R Offline
    R Offline
    Ratzz
    wrote on 15 Oct 2015, 12:35 last edited by
    #43

    @mrjj
    Not it does not allow even the treeview items to drop

    --Alles ist gut.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 15 Oct 2015, 12:41 last edited by
      #44

      STOP
      sender() not working for events it seems.
      So cannot work.
      So its a no go.

      R 1 Reply Last reply 15 Oct 2015, 12:42
      0
      • M mrjj
        15 Oct 2015, 12:41

        STOP
        sender() not working for events it seems.
        So cannot work.
        So its a no go.

        R Offline
        R Offline
        Ratzz
        wrote on 15 Oct 2015, 12:42 last edited by
        #45

        @mrjj
        ok fine.. what next?!

        --Alles ist gut.

        M 1 Reply Last reply 15 Oct 2015, 13:01
        0
        • R Ratzz
          15 Oct 2015, 12:42

          @mrjj
          ok fine.. what next?!

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 15 Oct 2015, 13:01 last edited by
          #46

          @Ratzz
          you can use
          QWidget * QDropEvent::source() const

          read here
          http://doc.qt.io/qt-5.5/qdropevent.html#source

          R 1 Reply Last reply 15 Oct 2015, 13:34
          0
          • M mrjj
            15 Oct 2015, 13:01

            @Ratzz
            you can use
            QWidget * QDropEvent::source() const

            read here
            http://doc.qt.io/qt-5.5/qdropevent.html#source

            R Offline
            R Offline
            Ratzz
            wrote on 15 Oct 2015, 13:34 last edited by
            #47

            @mrjj
            this way?

                void dragEnterEvent(QDragEnterEvent* event) {
                    QWidget * theone= dynamic_cast<QWidget*>(event->source());
                    if( theone == NULL )
                    {
                        event->acceptProposedAction();
                    }
                }

            --Alles ist gut.

            M 1 Reply Last reply 15 Oct 2015, 13:36
            0
            • R Ratzz
              15 Oct 2015, 13:34

              @mrjj
              this way?

                  void dragEnterEvent(QDragEnterEvent* event) {
                      QWidget * theone= dynamic_cast<QWidget*>(event->source());
                      if( theone == NULL )
                      {
                          event->acceptProposedAction();
                      }
                  }
              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 15 Oct 2015, 13:36 last edited by mrjj
              #48

              @Ratzz
              almost but must be the type you want to allow
              QTreeView * theone= dynamic_cast<QTreeView*>(event->source());
              if( theone != NULL )
              {
              event->acceptProposedAction();
              }

              so it says if it IS a Treeview then say ok
              For other types, it should not allow then. (red sign)
              I hope :)

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Ratzz
                wrote on 15 Oct 2015, 13:39 last edited by Ratzz
                #49

                @mrjj
                yes its working fine :)
                i should implement for Pushbutton also .

                --Alles ist gut.

                M 1 Reply Last reply 15 Oct 2015, 13:40
                0
                • R Ratzz
                  15 Oct 2015, 13:39

                  @mrjj
                  yes its working fine :)
                  i should implement for Pushbutton also .

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 15 Oct 2015, 13:40 last edited by
                  #50

                  @Ratzz
                  Super :)

                  R 1 Reply Last reply 16 Oct 2015, 05:18
                  0
                  • M mrjj
                    15 Oct 2015, 13:40

                    @Ratzz
                    Super :)

                    R Offline
                    R Offline
                    Ratzz
                    wrote on 16 Oct 2015, 05:18 last edited by
                    #51

                    @mrjj
                    when i click delete button i do ui->label->setText(QString::number(parent->rowCount())); which gives me count of the number of rows. But if i drag the row will be deleted but count is not getting updated. how to update it ?
                    Should it be done on GroupDropBox??

                    --Alles ist gut.

                    M 1 Reply Last reply 16 Oct 2015, 06:25
                    0
                    • R Ratzz
                      16 Oct 2015, 05:18

                      @mrjj
                      when i click delete button i do ui->label->setText(QString::number(parent->rowCount())); which gives me count of the number of rows. But if i drag the row will be deleted but count is not getting updated. how to update it ?
                      Should it be done on GroupDropBox??

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 16 Oct 2015, 06:25 last edited by
                      #52

                      @Ratzz
                      GroupBox would not know about parent.
                      The Tree should update when the It is removed.

                      But then you drag, do you call the buttons on_click so the
                      ui->label->setText(QString::number(parent->rowCount()))
                      is executed ?
                      The groupBox example does not call anything as the Tree removes the item it self so
                      I assume that is why you dont see Count Changes.

                      M 1 Reply Last reply 16 Oct 2015, 07:59
                      0
                      • M mrjj
                        16 Oct 2015, 06:25

                        @Ratzz
                        GroupBox would not know about parent.
                        The Tree should update when the It is removed.

                        But then you drag, do you call the buttons on_click so the
                        ui->label->setText(QString::number(parent->rowCount()))
                        is executed ?
                        The groupBox example does not call anything as the Tree removes the item it self so
                        I assume that is why you dont see Count Changes.

                        M Offline
                        M Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on 16 Oct 2015, 07:59 last edited by
                        #53

                        Hi
                        you could also cheat a bit and use a timer.

                        QTimer *timer = new QTimer(this);
                        connect(timer, SIGNAL(timeout()), this, SLOT(updateMinorFrameCount()));
                        timer->start(1000);

                        R 1 Reply Last reply 16 Oct 2015, 08:06
                        1
                        • M mrjj
                          16 Oct 2015, 07:59

                          Hi
                          you could also cheat a bit and use a timer.

                          QTimer *timer = new QTimer(this);
                          connect(timer, SIGNAL(timeout()), this, SLOT(updateMinorFrameCount()));
                          timer->start(1000);

                          R Offline
                          R Offline
                          Ratzz
                          wrote on 16 Oct 2015, 08:06 last edited by
                          #54

                          @mrjj
                          cheating works fine :)

                          --Alles ist gut.

                          1 Reply Last reply
                          0

                          52/54

                          16 Oct 2015, 06:25

                          • Login

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