Results 1 to 4 of 4

Thread: QCompleter display

  1. #1

    Default QCompleter display

    Hi,

    I want to display Completer ,when my line edit text is empty


    How do i do these?


    Thanks

    Addu

  2. #2
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QCompleter display

    QCompleter::complete(QRect) from your lineedit/textedit...

  3. #3

    Default Re: QCompleter display

    Hi

    Completer pop up is not displayed , while line edit text is empty

    code

    completer = new QCompleter(wordList, ui->lineEdit);

    completer->setCompletionMode(QCompleter::PopupCompletion);
    ui->lineEdit->setCompleter(completer);
    ui->lineEdit->completer()->complete();
    even

    ui->lineEdit->completer()->popup()->show(); is not helping me to show completer popup



    Thanks

    Addu R

  4. #4
    Join Date
    Apr 2009
    Posts
    46
    Thanks
    4
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QCompleter display

    If you are are calling complete() in constructor then you can notice that the popup actually appears for a moment just before the main window. Best solution would be probably this:

    Qt Code:
    1. QAction* action = new QAction(this);
    2. action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Space));
    3. ui->lineEdit->addAction(action);
    4. connect(action, SIGNAL(triggered()), completer, SLOT(complete()));
    To copy to clipboard, switch view to plain text mode 

    But if you really want the popup to appear together with main window then this could do the trick:
    Qt Code:
    1. ...
    2. QTimer::singleShot(250, this, SLOT(func()));
    3. }
    4.  
    5. void MainWindow::func()
    6. {
    7. completer->complete();
    8. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Qcompleter
    By wambagilles in forum Qt Programming
    Replies: 7
    Last Post: 6th April 2011, 08:14
  2. a smarter QCompleter
    By ber_44 in forum Qt Programming
    Replies: 7
    Last Post: 30th March 2011, 07:10
  3. Replies: 0
    Last Post: 17th September 2010, 12:19
  4. QCompleter Help
    By shinegun in forum Qt Programming
    Replies: 0
    Last Post: 2nd September 2010, 13:26
  5. Replies: 1
    Last Post: 12th October 2008, 08:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.