Results 1 to 4 of 4

Thread: QComboBox MaxVisibleItems overflow

  1. #1
    Join Date
    Feb 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Wink QComboBox MaxVisibleItems overflow

    I tried setting MaxVisibleItems of QComboBox.

    I tried coding something like :
    Qt Code:
    1. QComboBox *combo = new QComboBox;
    2. combo->setModel(queryModel);
    3. combo->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    4.  
    5. // MaxVisibleItems set
    6. QCompleter *p = new QCompleter(queryModel);
    7. p->setMaxVisibleItems(20);
    8. combo->setCompleter(p);
    9. combo->show();
    To copy to clipboard, switch view to plain text mode 

    The code execute, then QComboBox Size is overflowed and it's height exceed screen size.
    QComboBox item count is 300.

    Why don't display so MaxVisibleItem as I'm setting?

    What's incorret?

    please, Somebody help me.

  2. #2
    Join Date
    Oct 2009
    Location
    Mexico
    Posts
    81
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    6
    Thanked 10 Times in 10 Posts

    Default Re: QComboBox MaxVisibleItems overflow

    the example no reproduce the problem. i create a model for use whit the example and i dont see any problem.


    please post a more complete example. if queryModel is a SQL model class. try to create a dummy DB to reproduce the problem
    a dummy DB is a sqlite DB whit one table, whit the data to cause the problem.

    Qt Code:
    1. // my model
    2. int numItems = 300;
    3. QStandardItemModel * queryModel = new QStandardItemModel(numItems , 1);
    4. for (int row = 0; row < numItems ; ++row) {
    5. QStandardItem *item = new QStandardItem(QString("row %0").arg(row));
    6. queryModel->setItem(row, 0, item);
    7.  
    8. }
    9.  
    10. // not my code.
    11. QComboBox *combo = new QComboBox;
    12. combo->setModel(queryModel);
    13. combo->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    14.  
    15. // MaxVisibleItems set
    16. QCompleter *p = new QCompleter(queryModel);
    17. p->setMaxVisibleItems(20);
    18. combo->setCompleter(p);
    19. combo->show();
    To copy to clipboard, switch view to plain text mode 
    Last edited by ecanela; 24th February 2010 at 02:23. Reason: updated contents

  3. #3
    Join Date
    Feb 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox MaxVisibleItems overflow

    First of all, thanks to your answer.

    Sorry, I told not about My Test OS.
    My Test Os is Linux.

    My code and Your code tested in My Linux machine, QComboBox's height exceed Screen size.

    I don't know why it is occurred.

    following attached file.

    ================================================== ==================================

    Quote Originally Posted by ecanela View Post
    the example no reproduce the problem. i create a model for use whit the example and i dont see any problem.


    please post a more complete example. if queryModel is a SQL model class. try to create a dummy DB to reproduce the problem
    a dummy DB is a sqlite DB whit one table, whit the data to cause the problem.

    Qt Code:
    1. // my model
    2. int numItems = 300;
    3. QStandardItemModel * queryModel = new QStandardItemModel(numItems , 1);
    4. for (int row = 0; row < numItems ; ++row) {
    5. QStandardItem *item = new QStandardItem(QString("row %0").arg(row));
    6. queryModel->setItem(row, 0, item);
    7.  
    8. }
    9.  
    10. // not my code.
    11. QComboBox *combo = new QComboBox;
    12. combo->setModel(queryModel);
    13. combo->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    14.  
    15. // MaxVisibleItems set
    16. QCompleter *p = new QCompleter(queryModel);
    17. p->setMaxVisibleItems(20);
    18. combo->setCompleter(p);
    19. combo->show();
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files

  4. #4
    Join Date
    Oct 2009
    Location
    Mexico
    Posts
    81
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    6
    Thanked 10 Times in 10 Posts

    Default Re: QComboBox MaxVisibleItems overflow

    problably you need upgrade the version of Qt.

    another option is try to simplify your code. and isolate the problem. maybe is a bug.

Similar Threads

  1. Replies: 8
    Last Post: 25th February 2009, 08:29
  2. QToolButton icon not updated in overflow menu
    By pabakertx in forum Qt Programming
    Replies: 2
    Last Post: 26th September 2007, 13:48
  3. QThread stack overflow when exiting
    By jakamph in forum Qt Programming
    Replies: 4
    Last Post: 11th May 2006, 17:56
  4. Qtable and Cell overflow
    By taylor34 in forum Qt Programming
    Replies: 1
    Last Post: 23rd February 2006, 09:23
  5. How to trap an QLCD overflow?
    By jamadagni in forum Qt Programming
    Replies: 1
    Last Post: 17th February 2006, 08:18

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.