Advertisement
tomasaccini

Untitled

Jul 18th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <QApplication>
  2. #include <QComboBox>
  3. #include <stdio.h>
  4.  
  5. void ordenar_combo(QComboBox& combo) {
  6.     size_t size = combo.count();
  7.     printf("%zu\n", size);
  8.     QString t1;
  9.     QString t2;
  10.     for (size_t i = 0; i < size / 2; ++i) {
  11.         t1 = combo.itemText(i);
  12.         t2 = combo.itemText(size - i - 1);
  13.         combo.setItemText(i, t2);
  14.         combo.setItemText(size - i - 1, t1);
  15.     }
  16. }
  17.  
  18. int main(int argc, char* argv[]) {
  19.     QApplication app(argc, argv);
  20.     QComboBox combo;
  21.     combo.addItem("1");
  22.     combo.addItem("2");
  23.     ordenar_combo(combo);
  24.     combo.show();
  25.     return app.exec();
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement