Results 1 to 9 of 9

Thread: Occurance of Duplicate items in QComboBox

  1. #1
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Occurance of Duplicate items in QComboBox

    Hi all

    Working on Qt4.1 on Intel MAC machine.

    I m using QComboBox to add the items , The items are added in the comBobox , when i access it for the first time , all the items that are added appears only once . but when i access it second time , duplicates of the inserted items are also appeared.

    For this not to happen , I also use.

    QComboBox->setDuplicatesEnabled ( false);

    But still , I find the duplicates of the items in the QComboBox.

    Pls help....


    Thanx & Regards
    Always Believe in Urself
    Merry

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Occurance of Duplicate items in QComboBox

    Could you show us the code you used to fill the combobox?

  3. #3
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Occurance of Duplicate items in QComboBox

    Yaa Sure....


    Qt Code:
    1. DriveInfo *tmp = pDriveListStart;
    2. while(tmp)
    3. {
    4. combo->addItem((const char *)tmp->DisplayLable);
    5. combo->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    6. combo->setMaxCount(4);
    7. tmp=tmp->next;
    8. }
    To copy to clipboard, switch view to plain text mode 

    tmp variable contains all the information about the drives in my system.


    Thanx
    Always Believe in Urself
    Merry

  4. #4
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Occurance of Duplicate items in QComboBox

    Is this a Qt3 or a Qt4 question. Your profile says that you have used Qt3 but the thread says otherwise.
    We can't solve problems by using the same kind of thinking we used when we created them

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Occurance of Duplicate items in QComboBox

    • Where is this filling done?
    • What's the original type of DriveInfo::DisplayLable? (just wondering about that C-cast)
    • What kind of slots do you have connected to combo box signals and exactly what do they do?
    • Are you catching any events belonging to the combo box?

    In another words, show us more (relevant) code, please. Show the code which creates the combo box and all the places where you do anything with the combo box (but nothing more).

    sunil: sizeAdjustPolicy is a property of Qt 4's combo box.
    J-P Nurmi

  6. #6
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Occurance of Duplicate items in QComboBox

    Thanx 4 all the replies..

    My this Problem is solved..

    but still I got a problem that I wont be able to view the contents of th combo properly
    even by using this property

    combo->setSizeAdjustPolicy(QComboBox::AdjustToContents );


    If , i'll increase the length of the combobox ,then I will be able to view all the contents otherwise not


    Thanx
    Always Believe in Urself
    Merry

  7. #7
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Occurance of Duplicate items in QComboBox

    jpn: Good catch !!, You did beat me there

    Quote Originally Posted by merry View Post
    Thanx 4 all the replies..

    My this Problem is solved..
    Thanx
    But could you please explain what the problem was and how it was solved.

    Have you set any restriction on the maximum width of the combo?
    We can't solve problems by using the same kind of thinking we used when we created them

  8. #8
    Join Date
    Jan 2007
    Posts
    326
    Thanks
    42
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Occurance of Duplicate items in QComboBox

    Originally posted by Sunil.Thaha

    But could you please explain what the problem was and how it was solved

    .
    Actually the problem is the no. of items inserting in the combo are repeating no. of times.

    Soln: actually its my fault, The function in which i am inserting items in the combo , is called no. of times .

    Originally posted by Sunil.Thaha
    Have you set any restriction on the maximum width of the combo?
    No I havent set any restriction on the max. width of the combo.

    Thanx
    Always Believe in Urself
    Merry

  9. #9
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Occurance of Duplicate items in QComboBox

    We can't solve problems by using the same kind of thinking we used when we created them

Similar Threads

  1. Automatically add items to a QComboBox (Qt4)
    By darkadept in forum Qt Programming
    Replies: 2
    Last Post: 19th May 2006, 15:32
  2. QcomboBox items
    By therealjag in forum Newbie
    Replies: 5
    Last Post: 27th March 2006, 08:21
  3. [QT3] QComboBox: Disable adding items on Enter-keypress
    By BrainB0ne in forum Qt Programming
    Replies: 7
    Last Post: 14th January 2006, 19:43

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.