Skip to content
  • QComplter with ToolTip

    Unsolved General and Desktop
    1
    0 Votes
    1 Posts
    522 Views
    No one has replied
  • 1 Votes
    2 Posts
    2k Views
    SikarjanS

    I made a small update on the code. In the delegate I reworked the highlight section:

    QAbstractTextDocumentLayout::PaintContext ctx; QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &optionV4); painter->save(); painter->translate(textRect.topLeft()); painter->setClipRect(textRect.translated(-textRect.topLeft())); // Highlighting text if item is selected if (optionV4.state & QStyle::State_Selected){ ctx.palette.setColor(QPalette::Text, optionV4.palette.color(QPalette::Active, QPalette::HighlightedText)); QStyleOptionViewItem toolTip = option; initStyleOption(&toolTip, index.sibling(index.row(),2)); QToolTip::showText(QPoint(textRect.right() + 15, textRect.top()), toolTip.text ); } doc.documentLayout()->draw(painter, ctx); painter->restore();

    This gives me a nice tool tip but not at the right location. I want it next to the completer but I cannot figure out how to get the coordinates. Since the delegate is not a widget I cannot use this->maptoglobal(). Any ideas on how I could position the tool tip next to the highlighted element?

  • 0 Votes
    1 Posts
    764 Views
    No one has replied
  • 0 Votes
    6 Posts
    6k Views
    A

    @raven-worx said in QCompleter in QTableView: show always, even before user input:

    declare the m_Editor variable as mutable.

    This makes it compile (even though I'm not sure about the implications), but it doesn't help me: there is no Show event handled in editorEvent ever (tested with printf-debugging - yes, before the test for QLineEdit), I'm only getting Mouse events.

    @SGaist said in QCompleter in QTableView: show always, even before user input:

    Something like completer->popup()->show(); should do what you want.

    Nope, does not help.

    I figured (using qDebug, again), the place where I should put my popup-opening call is setEditorData. In there, I receive the QLineEdit and it's QCompleter: But I cannot make it show the popup. I tried now:

    completer->setCompletionPrefix(index.data(Qt::EditRole).toString()); completer->complete(); completer->popup()->show();

    Note: Sometimes the popup is shown for a very short time, but immediately hides. When repeatedly entering & leaving edit mode this only works the first time.

  • 0 Votes
    1 Posts
    727 Views
    No one has replied