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. Preventing QCompleter from modifying the content during selection
Forum Updated to NodeBB v4.3 + New Features

Preventing QCompleter from modifying the content during selection

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 330 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
    riplin
    wrote on last edited by
    #1

    Hi folks,

    I'm trying to prevent a QCompleter from modifying the content of the text box while the user is cycling through the options.

    Ideally I want it to just send a signal of some sort when the user clicks or presses enter on an item. Is this possible?

    My setup is as follows:

    auto* lineEdit = new QLineEdit(parent);
    auto* completerListView = new QListView(parent);
    auto* completer = new QCompleter(parent);
    completer->setPopup(completerListView);
    auto* completerModel = new CompleterModel();
    completer->setCompletionMode(QCompleter::CompletionMode::UnfilteredPopupCompletion);
    completer->setModelSorting(QCompleter::ModelSorting::UnsortedModel);
    lineEdit->setCompleter(completer);
    
    return lineEdit;
    
    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by ChrisW67
      #2

      Is there something wrong with the QLineEdit::editingFinished(), QLineEdit::textChanged(), or QLineEdit::returnPressed() signals?

      1 Reply Last reply
      0
      • R Offline
        R Offline
        riplin
        wrote on last edited by riplin
        #3

        I'm not sure what you mean? The QLineEdit isn't the problem.

        What I'm looking for is preventing the QCompleter from modifying the content of the QLineEdit when the user cursors through the items presented by the QCompleter. I want the text typed by the user to stay as it was typed while they are able to change the highlighted item in the QCompleter.

        Ideally I'd like something equivalent to a Qt::NoneRole if I were to call setCompletionRole and instead manage the setting myself through a signal sent by the QCompleter when a choice is made by the user. Yes, I'm aware there is no Qt::NoneRole.

        Edit: Basically it's best summed up as: I want to prevent the QCompleter from modifying the QLineEdit and want to do that myself.

        1 Reply Last reply
        0

        • Login

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