QSA-interest Archive, February 2006
ComboBox preselection overwrites item list
Message 1 in thread
I want to preselect the item "b" in the script below, however this
overwrites the itemList and changes the drop-down list to ["b", "b",
"c"]. Is this a bug or am I doing something wrong?
function test()
{
var d = new Dialog;
d.caption = "Test";
d.okButtonText = "OK";
d.cancelButtonText = "Cancel";
var c = new ComboBox;
c.label = "Select: ";
c.itemList = ["a", "b", "c"];
c.currentItem = "b";
d.add( c );
d.exec();
}
--
[ signature omitted ]
Message 2 in thread
Seneca wrote:
>I want to preselect the item "b" in the script below, however this
>overwrites the itemList and changes the drop-down list to ["b", "b",
>"c"]. Is this a bug or am I doing something wrong?
>
>
>
...
> c.itemList = ["a", "b", "c"];
> c.currentItem = "b";
>
>
...
Hi, Seneca.
This is a bug in QSA, unfortunately. It will be fixed for maintenance
releases QSA 1.2.1 and QSA 1.1.4. Meanwhile, here's a patch for QSA 1.2.0.
best regards,
Eskil
==== src/qsa/qsinputdialogfactory.cpp#14 - src\qsa\qsinputdialogfactory.cpp ====
==== src/qsa/qsinputdialogfactory.cpp#14 - src\qsa\qsinputdialogfactory.cpp ====
@@ -627,7 +627,11 @@ public:
QString currentItem() const
{ return d()->currentText(); }
void setCurrentItem(const QString &txt)
- { d()->setItemText(d()->currentIndex(), txt); }
+ {
+ int idx = d()->findText(txt);
+ if (idx >= 0)
+ d()->setCurrentIndex(idx);
+ }
bool isEditable() const
{ return d()->isEditable(); }
void setEditable(bool b)
Message 3 in thread
Hello Eskil,
EAB> This is a bug in QSA, unfortunately. It will be fixed for
EAB> maintenance releases QSA 1.2.1 and QSA 1.1.4. Meanwhile, here's a
EAB> patch for QSA 1.2.0.
Thanks for the patch, it works perfectly.
--
[ signature omitted ]