Results 1 to 4 of 4

Thread: removing old list and adding new list to qcompleter

  1. #1
    Join Date
    Dec 2016
    Posts
    30
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Windows Android

    Default removing old list and adding new list to qcompleter

    hi i need to remove old qstringlist of qcompleter and add a new one. how can i di this.
    for example i have this:
    Qt Code:
    1. QStringList stringList;
    2. stringList << "m0" << "m1" << "m2";
    3. mCompleter = new QCompleter(stringlist, this);
    4. mLineEdit->setCompleter(mCompleter);
    To copy to clipboard, switch view to plain text mode 

    now i want to remove stringlist and clear mCompleter and add stringlist2:
    Qt Code:
    1. QStringList stringList2;
    2. stringList2<< "m" << "mm" << "mmm";
    3. //removing stringlist here!
    4. //adding stringlist2 here!
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: removing old list and adding new list to qcompleter

    Qt Code:
    1. QStringList stringList2;
    2. stringList2<< "m" << "mm" << "mmm";
    3.  
    4. mCompleter->setModel( new QStringListModel( stringList2, mCompleter ) );
    To copy to clipboard, switch view to plain text mode 

    See QCompleter::setModel() to understand why mCompleter is used in the QStringListModel constructor.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Dec 2016
    Posts
    30
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: removing old list and adding new list to qcompleter

    Quote Originally Posted by d_stranz View Post
    Qt Code:
    1. QStringList stringList2;
    2. stringList2<< "m" << "mm" << "mmm";
    3.  
    4. mCompleter->setModel( new QStringListModel( stringList2, mCompleter ) );
    To copy to clipboard, switch view to plain text mode 

    See QCompleter::setModel() to understand why mCompleter is used in the QStringListModel constructor.

    thanks for replying but crashes while using
    mCompleter->setModel( new QStringListModel( stringList2, mCompleter ) );

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: removing old list and adding new list to qcompleter

    but crashes
    And what does the debugger say about why the crash occurs? From your original code for creating the QCompleter in the first place and this code for changing the string list, it seems to follow what is described in the documentation. You don't show where you're actually using this code though, so that's why you need to look at what the debugger says.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 9
    Last Post: 24th January 2016, 18:19
  2. Replies: 1
    Last Post: 4th July 2012, 12:17
  3. Replies: 1
    Last Post: 23rd April 2011, 17:33
  4. Replies: 4
    Last Post: 21st January 2011, 01:27
  5. Qt Kinetic: adding items to list
    By Diph in forum Qt Programming
    Replies: 1
    Last Post: 10th November 2009, 08:27

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.