In QComboBox, how can I align the text to centre? Currently (in Maemo 5 at least) the text is aligned left.
Also (again in Maemo 5) there is this "title" when it's open. How can I change that? Currently it's showing the app name only.
Cheers![]()
In QComboBox, how can I align the text to centre? Currently (in Maemo 5 at least) the text is aligned left.
Also (again in Maemo 5) there is this "title" when it's open. How can I change that? Currently it's showing the app name only.
Cheers![]()
You can do something like this:
Code:#include <QApplication> #include <QMainWindow> #include <QComboBox> #include <QAbstractItemView> #include <QDebug> int main(int argc, char* argv[]) { QApplication app(argc,argv); QComboBox *combo = new QComboBox; combo->addItem("item1"); combo->addItem("item2"); combo->addItem("item3"); combo->addItem("item4"); QAbstractItemView *view = combo->view(); QAbstractItemModel *model = view->model(); model->setData(model->index(0, 0), QVariant(Qt::AlignCenter), Qt::TextAlignmentRole); QMainWindow w; w.setCentralWidget(combo); w.show(); return app.exec(); }
Hi Daniil,
I tried your code in Qt4.7, and it seems not to work. The alignment is still "left" for all items in combobox. Actually I'm meeting the same problem when I try to modify the text alignment of combobox on N900 with maemo5 firmware 1.3. So do you have any other idea for solving this problem?
It works perfectly for me. Note that PR1.3 contains Qt 4.7, while Nokia Qt SDK 1.0.1 still has Qt 4.6. This mismatch can cause any deviations.