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
Re: Occurance of Duplicate items in QComboBox
Could you show us the code you used to fill the combobox?
Re: Occurance of Duplicate items in QComboBox
Yaa Sure....
Code:
DriveInfo *tmp = pDriveListStart;
while(tmp)
{
combo->addItem((const char *)tmp->DisplayLable);
combo
->setSizeAdjustPolicy
(QComboBox::AdjustToContents);
combo->setMaxCount(4);
tmp=tmp->next;
}
tmp variable contains all the information about the drives in my system.
Thanx
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.
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.
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
Re: Occurance of Duplicate items in QComboBox
jpn: Good catch !!, You did beat me there :)
Quote:
Originally Posted by
merry
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?
Re: Occurance of Duplicate items in QComboBox
Quote:
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 .
Quote:
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
Re: Occurance of Duplicate items in QComboBox