Drag And Drop tableWidget to tableWidget Item Moved Has No Effect



  • Hello guys.
    I'm doing drag and drop.
    When I take item one from the other does not have the effect.
    alt text

    1. In this picture I want to move the selected item on dlgGroups table And I want to see this item at the moment of transition. How I Can this?
    2. After Drop I dont Need item named "new" wont have active border.

    dlgGroups.cpp

    
    void dlgGroups::dragEnterEvent(QDragEnterEvent *event)
    {
        QTableWidget::dragEnterEvent(event);
    }
    
    void dlgGroups::dragMoveEvent(QDragMoveEvent *event)
    {
        QTableWidget::dragMoveEvent(event);
    }
    
    void dlgGroups::dragLeaveEvent(QDragLeaveEvent *event)
    {
        QTableWidget::dragLeaveEvent(event);
    }
    
    void dlgGroups::dropEvent(QDropEvent *event)
    {
        if (event->source() != m_table){
            return;
        }
    
        QTableWidgetItem *currentITEM = this->currentItem();
        int currentUID = this->item(this->currentRow(), 0)->text().toInt();
    
        QTableWidgetItem *m_item = this->itemAt(event->pos());
        if (!(m_item)) {
            return;
        }
    
        if (m_item->row() == 0) { // Is Top Level Item
            QMessageBox::information(0, "Daxi SMS Sender", "?? ??????? ??? ?????????");
            return;
        }
    
        int CUID = m_table->item(m_table->currentRow(), 1)->text().toInt();
        int GroupUID = this->item(m_item->row(), 0)->text().toInt();
    
        //Check User if Used
        std::vector<std::pair<int, int> > my_vector = globalall->myMap[GroupUID];
        for (unsigned int i = 0; i < my_vector.size(); i++) {
            std::pair<int, int> pr = my_vector[i];
            if (CUID == pr.second){
                this->setCurrentIndex(this->model()->index(currentITEM->row(), currentITEM->column()));
                //this->itemChanged(currentITEM);
                QMessageBox::information(0, "Daxi SMS Sender", "???????? ???? ???? ?? ???????.");
                return;
            }
        }
        // ////////////////////////////////////////////////////////////////////////////////////////////
    
        cellClicked(m_item->row(), m_item->column());
    
        if (globalall->db.open()) {
            QSqlQuery InsertQry;
            int LastInsertID = -1;
            InsertQry.prepare("INSERT INTO ContactGroups(GroupsUID, ContactUID) VALUES (:oGroupsUID, :oContactUID)");
            InsertQry.bindValue(":oGroupsUID", GroupUID);
            InsertQry.bindValue(":oContactUID", CUID);
            if (InsertQry.exec()) {
                LastInsertID = InsertQry.lastInsertId().toInt();
                emit DeletePreviuousRow(currentUID, CUID);
            } else {
                QMessageBox::information(0, "Daxi SMS Sender", "????????? ??? ????????.");
                return;
            }
    
            QModelIndex index = this->model()->index(m_item->row(), m_item->column());
            this->setCurrentIndex(index);
    
            Contact *cont = globalall->GetConact(CUID);
            m_table->insertRow(0);
            m_table->setItem(0, 0, globalall->GetNewItem(QString::number(LastInsertID), QIcon("")));
            m_table->setItem(0, 1, globalall->GetNewItem(cont->UID, QIcon("")));
            m_table->setItem(0, 2, globalall->GetNewItem(this->item(m_item->row(), 1)->checkState(), QIcon(""), Qt::CheckStateRole));
            m_table->setItem(0, 3, globalall->GetNewItem(cont->Name + " " + cont->FamilyName, QIcon(":/SMSicons/user.png")));
            m_table->setItem(0, 4, globalall->GetNewItem(cont->Mobile, QIcon(":/SMSicons/mobile.ico")));
            m_table->setItem(0, 5, globalall->GetNewItem(cont->Type ? cont->Identification : cont->PersonID, QIcon("")));
            m_table->setRowHeight(0, 23);
    
            emit ContactInSerted(this->item(m_item->row(), 0)->text().toInt(), LastInsertID, cont->UID);
    
            globalall->db.close();
        }
    }
    

    dlgGroups Constructor:

        setMinimumSize(231, 341);
        setMaximumSize(231, 341);
        setAcceptDrops(true);
        setDropIndicatorShown(true);
        setAutoFillBackground(true);
    
        setColumnCount(3);
        hideColumn(0);
        setColumnWidth(1, 20);
        setColumnWidth(2, this->width() - 40);
        this->verticalHeader()->hide();
        setHorizontalHeaderLabels(QStringList() << "" << "" << "?????????? ??????????");
        this->setContextMenuPolicy(Qt::CustomContextMenu);
    
        connect(this, SIGNAL(cellClicked(int,int)), this, SLOT(thiscellClicked(int,int)));
        connect(this, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(thisitemChanged(QTableWidgetItem*)));
        connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(thiscustomContextMenuPolicy(QPoint)));
    


  • Question 1.
    @Taz742 said in Drag And Drop tableWidget to tableWidget Item Moved Has No Effect:

    In this picture I want to move the selected item on dlgGroups table And I want to see this item at the moment of transition. How I Can this?

    I work with this application RDP connection and installed are windows 8.3 I opened my application on windows 10 and Question 1 is worked. i dont know this problem RDP Connection ? Windows 8.3 ?

    Now Left Question 2.

    @Taz742 said in Drag And Drop tableWidget to tableWidget Item Moved Has No Effect:

    After Drop I dont Need item named "new" wont have active border.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.