Skip to content
  • 0 Votes
    3 Posts
    1k Views
    patrikdP

    @sk2212
    cool, thx!

  • 0 Votes
    2 Posts
    2k Views
    mrjjM

    Hi and welcome

    Maybe
    void QDrag::setPixmap(const QPixmap & pixmap)
    Could be used ?
    You set it when you start the drag so it sounds it might do what you want.

  • 0 Votes
    2 Posts
    3k Views
    SGaistS

    Hi and welcome to devnet,

    What about using setCurrentIndex ?

  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • 0 Votes
    2 Posts
    1k Views
    SGaistS

    Hi,

    Do you mean get additional data using QSqlQuery ?

  • 0 Votes
    12 Posts
    7k Views
    SGaistS

    Sorry for the late reply, the page says that there's nothing to be found

  • 0 Votes
    3 Posts
    1k Views
    S

    Hi, thanks for the reply. Yes, I set that flag to true but I can select a row by clicking indivual cell or horizontal header. I've overriden flags function in my model if I remove isSelectable flag i can't select anything.

    Qt::ItemFlags TableModel::flags(const QModelIndex &index) const { if(!index.isValid()) { return Qt::ItemIsEnabled; } if(index.column() == 1) { if(modelList.at(index.row()).isArray) { return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEditable; } return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable; } return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable; }
  • 0 Votes
    12 Posts
    9k Views
    C

    I got the Clipboard error when I had RealVncViewer running at the same time. I closed VNC & then the application ran without the clipboard error.

  • 0 Votes
    2 Posts
    8k Views
    p3c0P

    @Adrianos How about using setSelected ? Since you already have the QTableWidgetItem .

  • 0 Votes
    6 Posts
    7k Views
    D

    In case you come across this a bit more complete example, including handling of contentY changing because of scroll...:

    MouseArea
    {id: selectionMouseArea
    property alias selectionRect : selectionRect
    property int initialXPos
    property int initialYPos
    property int mouseX
    property int mouseY
    anchors.fill: grid
    acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton

    Rectangle {id: selectionRect visible: false x: 0 y: 0 z: 99 width: 0 height: 0 rotation: 0 radius: 5 color: "#5F227CEB" border.width: 1 border.color: "#103A6E" transformOrigin: Item.TopLeft } //selectionRect //moving close to top or bot end scrolls view depending on speed Timer {repeat: true;running: ( parent.mouseY < 0 && grid.contentY>0 ) && parent.pressed && !grid.atYBeginning; interval: 10; onTriggered: grid.contentY -= (-1 * parent.mouseY), returnToBounds() } Timer {repeat: true;running: ( parent.mouseY > grid.height) && parent.pressed && !grid.atYEnd interval: 10; onTriggered: grid.contentY += 1 * ( parent.mouseY -grid.height ), returnToBounds() } //makes the rectangle smooth Connections { target: grid onContentYChanged: //selectionRect needs to be depending onConentY as its size and position depends on that { if (selectionRect.rotation == 0 || selectionRect.rotation == -180) { selectionRect.y = selectionMouseArea.initialYPos - grid.contentY selectionRect.height = Math.abs(selectionMouseArea.mouseY - selectionMouseArea.initialYPos + grid.contentY) selectionRect.width = Math.abs(selectionMouseArea.mouseX - selectionRect.x) } else { selectionRect.y = selectionMouseArea.initialYPos - grid.contentY selectionRect.height = Math.abs(selectionMouseArea.mouseX - selectionRect.x) selectionRect.width = Math.abs(selectionMouseArea.mouseY - selectionRect.y) } } } onClicked: { if(mouse.button == Qt.RightButton) { mouse.accepted=false return; } if ( wasHeld || mouse.modifiers & Qt.ControlModifier ) return; initialXPos=mouse.x; initialYPos=mouse.y;mouseX=mouse.x;mouseY=mouse.y } onPressed: { if(mouse.button == Qt.RightButton) { mouse.accepted=false return; } if (mouse.modifiers & Qt.ControlModifier) { console.log("ControlModifier"); mouse.accepted=false return; } if (mouse.button == Qt.LeftButton) { initialXPos = mouse.x initialYPos = mouse.y+grid.contentY grid.interactive = false selectionRect.x = mouse.x selectionRect.y = mouse.y selectionRect.width = 0 selectionRect.height = 0 } if(itemAt(mouse.x,mouse.y+grid.contentY).hovered) mouse.accepted=false if(itemAt(mouse.x,mouse.y+grid.contentY).hovered===false) { ufm().resetSelection() grid.currentIndex=-1 } } onPositionChanged: { // console.log(selectionRect.height); // console.log(selectionRect.width); if(mouse.button == Qt.RightButton) { mouse.accepted=false return; } if (mouse.modifiers & Qt.ControlModifier) { return; } selectionRect.visible = true if (selectionRect.visible === false) { selectionRect.x = 0 selectionRect.y = 0 selectionRect.width = 0 selectionRect.height = 0 initialXPos = 0 initialYPos = 0 } if (selectionRect.visible === true) { mouseX = mouse.x mouseY = mouse.y if (Math.abs(mouseX, initialXPos)>30) wasHeld = true if (Math.abs(mouseY, initialYPos)>30) wasHeld = true if (mouse.x >= initialXPos) { if (mouse.y+grid.contentY >= initialYPos) selectionRect.rotation = 0 else selectionRect.rotation = -90 } else if (mouse.x <= initialXPos) { if (mouse.y+grid.contentY >= initialYPos) selectionRect.rotation = 90 else selectionRect.rotation = -180 } if (selectionRect.rotation == 0 || selectionRect.rotation == -180) { selectionRect.y = initialYPos - grid.contentY selectionRect.height = Math.abs(mouse.y - initialYPos + grid.contentY) selectionRect.width = Math.abs(mouse.x - selectionRect.x) } else { selectionRect.y = initialYPos - grid.contentY selectionRect.height = Math.abs(mouse.x - selectionRect.x) selectionRect.width = Math.abs(mouse.y - selectionRect.y) } } } onReleased: { selectionRect.visible = false // restore the Flickable duties grid.interactive = true } onWheel: { if (wheel.angleDelta.y > 0 && !grid.atYBeginning) grid.contentY -= 50 else if (wheel.angleDelta.y < 0 && !grid.atYEnd) grid.contentY += 50 }

    }

  • 0 Votes
    1 Posts
    813 Views
    No one has replied