PDA

View Full Version : Occurance of Duplicate items in QComboBox



merry
11th September 2007, 06:57
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

wysota
11th September 2007, 09:15
Could you show us the code you used to fill the combobox?

merry
11th September 2007, 10:59
Yaa Sure....



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

sunil.thaha
11th September 2007, 11:23
Is this a Qt3 or a Qt4 question. Your profile says that you have used Qt3 but the thread says otherwise.

jpn
11th September 2007, 11:38
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 (http://doc.trolltech.com/4.3/qcombobox.html#sizeAdjustPolicy-prop) is a property of Qt 4's combo box.

merry
11th September 2007, 12:25
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

sunil.thaha
11th September 2007, 14:22
jpn: Good catch !!, You did beat me there :)


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?

merry
11th September 2007, 15:17
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

sunil.thaha
12th September 2007, 16:05
See if this helps
http://trolltech.com/developer/knowledgebase/faq.2007-09-04.4047853088