qt - Adding Icons to Combobox Items such that Icons are visible at the Right Side -
i working on application in need show list of program names , corresponding icons in combobox popup menu.
i tried following things: a. created custom widget deriving qcombobox b. reimplemented showpopup() function follows
void cmycombobox::showpopup() { qcombobox::showpopup(); mp_popup = this->findchild<qframe *>(); mp_popup->move( mp_popup->x(), mp_popup->y() - this->height() - mp_popup->height() ); }
c. adding items combobox qstring name = "xyz"; qicon icon("sample.png");
mycombobox->insertitem(0, icon, name);
question is: when insert using above method, inserts icon @ left side(i.e.., icon followed name) . how make icons come @ right side(i.e.., first name followed icon)
regards santhosh
qcombobox
uses qabstractmodel
showing data. can replace standard model custom 1 using function void qcombobox::setmodel ( qabstractitemmodel * model )
.
icon position in relation text controlled via style options. should this:
qstyleoptionviewitem option; option.decorationalignment = qt::alignright | qt::alignvcenter; option.decorationposition = qstyleoptionviewitem::top;
Comments
Post a Comment