Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: C++  |  size: 1.20 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <QtCore/QAbstractItemModel>
  2. #include <QtCore/QLatin1String>
  3. #include <QtGui/QGuiApplication>
  4. #include <QtQml/QtQml>
  5. #include <QtQuick/QQuickView>
  6.  
  7. #include <QWidget>
  8. #include <QLabel>
  9. #include <QComboBox>
  10. #include <QVBoxLayout>
  11. #include <QPushButton>
  12. #include <QApplication>
  13. #include <QDebug>
  14.  
  15. int main(int argc, char** argv)
  16. {
  17.     /*QGuiApplication app(argc, argv);
  18.  
  19.     qmlRegisterType<PopupWindow>("ComboTest", 1, 0, "PopupWindow");
  20.  
  21.     QQuickView *view = new QQuickView;
  22.     view->setSource(QUrl::fromLocalFile("main.qml"));
  23.     view->show();*/
  24.  
  25.     QApplication app(argc, argv);
  26.  
  27.     QWidget *win = new QWidget;
  28.     QVBoxLayout *layout = new QVBoxLayout;
  29.     QComboBox *combo = new QComboBox;
  30.     combo->addItem("AAAaaAAAaAA");
  31.     combo->addItem("BBBbbBBbbBB");
  32.     combo->addItem("CCCCccCCCcC");
  33.     combo->addItem("CCC");
  34.     combo->setEditable(true);
  35.     //combo->setCurrentIndex(-1);
  36.     qDebug() << combo->currentIndex();
  37.     layout->addWidget(new QLabel("(Label)ComboBox:"));
  38.     layout->addWidget(new QPushButton("PushButton"));
  39.     layout->addWidget(combo);
  40.     win->setBaseSize(400, 200);
  41.     win->setLayout(layout);
  42.     win->show();
  43.  
  44.     return app.exec();
  45. }