Skip to content
  • 0 Votes
    3 Posts
    2k Views
    Sounds great, but I get some runtime error: QPainter::begin: Paint device returned engine == 0, type: 2 QWidget::render: Cannot render with an inactive painter Edit: There is some modification on your suggested code neccessary: const QModelIndex& index = currentIndex(); // Render the pixmap QPixmap pixmap(visualRect(index).size()); //pixmap. render(&pixmap, QPoint(), visualRect(index)); // Create the drag QDrag* drag = new QDrag(this); drag->setPixmap(pixmap); ... But anyhow it renders the cell of one index above the selected one. Maybe that has something to do with the offset parameter (second one in render). Edit2: The proper QRect can be calculated with the height of the horizontal header: render(&pixmap, QPoint(0,0), visualRect(index).translated(0, horizontalHeader()->height() ));