Example #1
0
File: main.cpp Project: RS102839/qt
int main(int argc, char **argv) {
    QApplication::setDesktopSettingsAware(false);
    QApplication app(argc, argv);
    QComboBox box;
    box.insertItem(0, "foo");
    box.setEditable(true);
    box.show();
    return 0;
}
Example #2
0
MyDialog::MyDialog(QWidget *parent) : QDialog(parent)
   {
     QComboBox *styleComboBox = new QComboBox(this);
     styleComboBox->addItems(QStyleFactory::keys());
     qDebug() << QStyleFactory::keys();
     QLabel *styleLabel = new QLabel(tr("&Style :"),this);
     styleLabel->setBuddy(styleComboBox);
     connect(styleComboBox, SIGNAL(activated(QString)), this, SLOT(changeStyle(QString)));
     styleComboBox->show();
styleLabel->show();
   }
//-----------------------------------------------------------------------------
int ctkVTKDataSetModelEventTranslatorPlayerTest1(int argc, char * argv [] )
{
  QApplication app(argc, argv);

  QString xmlDirectory = CTK_SOURCE_DIR "/Libs/Visualization/VTK/Widgets/Testing/Cpp/";

  // ------------------------
  ctkEventTranslatorPlayerWidget etpWidget;
  pqTestUtility* testUtility = new pqTestUtility(&etpWidget);
  etpWidget.setTestUtility(testUtility);

  // Test case 1
  vtkSmartPointer<vtkPolyData> dataSet =
      vtkSmartPointer<vtkPolyData>::New();
  vtkSmartPointer<vtkIntArray> ints = vtkSmartPointer<vtkIntArray>::New();
  ints->SetName("Ints");
  dataSet->GetPointData()->AddArray(ints);
  vtkSmartPointer<vtkFloatArray> floats= vtkSmartPointer<vtkFloatArray>::New();
  floats->SetName("Floats");
  dataSet->GetCellData()->AddArray(floats);

  ctkVTKDataSetModel dataSetModel;
  dataSetModel.setDataSet(dataSet);

  QComboBox comboBox;
  comboBox.setModel(&dataSetModel);
  comboBox.show();

  QSignalSpy spy1(&comboBox, SIGNAL(currentIndexChanged(QString)));
  Spy1 = &spy1;

  etpWidget.addTestCase(&comboBox,
                        xmlDirectory + "ctkVTKDataSetModelEventTranslatorPlayerTest1.xml",
                        &checkFinalWidgetState);

  // ------------------------
  if (!app.arguments().contains("-I"))
    {
    QTimer::singleShot(0, &etpWidget, SLOT(play()));
    }

  etpWidget.show();
  return app.exec();
}
Example #4
0
QtTutorial::QtTutorial(QWidget *parent)
	: QMainWindow(parent)
{

	// ALL OF OUR VIEWS
	QListView *listView = new QListView();
	listView->show();

	QTreeView *treeView = new QTreeView();
	treeView->show();

	QComboBox *comboBox = new QComboBox();
	comboBox->show();

	QTableView *tableView = new QTableView();
	tableView->show();

	// RGBA
	QColor red = QColor(255, 0, 0, 255);
	QColor green = QColor(0, 255, 0, 255);
	QColor blue = QColor(0, 0, 255, 255);

	QList<QColor> items;
	items.append(red);
	items.append(green);
	items.append(blue);

	int rowCount = 4;
	int columnCount = 6;

	PaletteListModel *model = new PaletteListModel(items);
	
	// Insert at Position 3 -> 5 empty rows
	model->insertRows(3, 5);

	// Remove from position 4 -> 1 row
	// model->removeRows(4,1);

	listView->setModel(model);
	comboBox->setModel(model);
	tableView->setModel(model);
    treeView->setModel(model);
}
void QgsPasteTransformations::addTransfer( const QString& sourceSelectedFieldName,
    const QString& destinationSelectedFieldName )
{
  QgsDebugMsg( QString( "From %1 to %2." ).arg( sourceSelectedFieldName ).arg( destinationSelectedFieldName ) );

  int newRow = gridLayout->rowCount();

// TODO: Do not add the transfer if neither the sourceSelectedFieldName nor the destinationSelectedFieldName could be found.

  // For some reason Qt4's uic3 only outputs generic names for layout items
  QComboBox* newSourceFields      = new QComboBox( gridLayout->parentWidget() );
  QComboBox* newDestinationFields = new QComboBox( gridLayout->parentWidget() );

  int count = 0;

  // Populate source fields
  for ( std::vector<QString>::iterator it  = mSourceFields.begin();
        it != mSourceFields.end();
        ++it )
  {
    newSourceFields->addItem(( *it ) );

    // highlight this item if appropriate
    if ( sourceSelectedFieldName == ( *it ) )
    {
      newSourceFields->setCurrentIndex( count );
    }

    count++;
  }

  count = 0;

  // Populate destination fields
  for ( std::vector<QString>::iterator it  = mDestinationFields.begin();
        it != mDestinationFields.end();
        ++it )
  {
    newDestinationFields->addItem(( *it ) );

    // highlight this item if appropriate
    if ( destinationSelectedFieldName == ( *it ) )
    {
      newDestinationFields->setCurrentIndex( count );
    }

    count++;
  }

  // Append to dialog layout
  gridLayout->addWidget( newSourceFields,      newRow, 0 );
  gridLayout->addWidget( newDestinationFields, newRow, 1 );

  // Keep a reference to them so that we can read from them
  // when the dialog is dismissed
  mSourceTransfers     .push_back( newSourceFields );
  mDestinationTransfers.push_back( newDestinationFields );

  // Reveal the new sub-widgets
  newSourceFields->show();
  newDestinationFields->show();

}
HardwareSettingsDialog::HardwareSettingsDialog(QWidget *parent, QString file, Hardware *module) :
    QDialog(parent),
    descriptorFile(file)
{
    hardwareModule = module;

    readDescriptorFromFile(descriptorFile);
    refreshRegisters();

    buttonOk = new QPushButton(this);
    buttonCancel = new QPushButton(this);

    buttonOk->resize(100, 25);
    buttonOk->setText(QString::fromLocal8Bit("Применить"));

    buttonCancel->resize(100, 25);
    buttonCancel->setText(QString::fromLocal8Bit("Отмена"));
    connect(buttonOk, SIGNAL(clicked()), this, SLOT(applySettings()));
    connect(buttonCancel, SIGNAL(clicked()), this, SLOT(cancelSettings()));

    // отрисовка найденых регистров на форме
    QVector<ModbusRegister*>::Iterator reg = registerVector.begin();
    int yPos = 10;
    int yStep = 30;
    int labelXsize = 200;
    int labelYsize = 25;
    int lineEditXsize = 150;
    int xDistance = 20;
    for (reg = registerVector.begin(); reg != registerVector.end(); ++reg) {
        if ((*reg)->getType() == ModbusRegister::reservType)
            continue;

        QLabel* text = new QLabel(this);

        text->show();
        text->move(5, yPos);
        text->resize(labelXsize, labelYsize);
        text->setText((*reg)->name);

        labelVector.push_back(text);

        switch ((*reg)->getType()) {
        case ModbusRegister::intType : {
                QLineEdit* edit = new QLineEdit(this);

                edit->move(labelXsize + xDistance, yPos);
                edit->resize(lineEditXsize, labelYsize);
                edit->setText(QString::number((*reg)->getData()));
                edit->show();
                lineeditVector.push_back(edit);
            }
            break;
        case ModbusRegister::textType : {
                QComboBox *box = new QComboBox(this);

                // заполняем список фозможными значениями
                int nText = (*reg)->stringText_.size();
                for (int j = 0; j < nText; j++) {
                    box->addItem((*reg)->stringText_[j]);
                }
                box->setCurrentIndex((*reg)->getData());
                // пихаем на форму
                box->move(labelXsize + xDistance, yPos);
                box->resize(lineEditXsize, labelYsize);
                box->show();
                boxVector.push_back(box);
            }
            break;
        default : break;
        }

        yPos += yStep;
    }

    yPos += yStep;
    buttonOk->move(400 - 100 - (400 - xDistance - labelXsize - lineEditXsize), yPos); // это придумал мой пьяный мозг, на самом деле нужно просто добавить компоновщик
    buttonCancel->move(400 - 100 - xDistance - 100 - (400 - xDistance - labelXsize - lineEditXsize), yPos);
    buttonCancel->show();
    buttonOk->show();
    yPos += yStep;

    this->resize(400, yPos + 25);
    this->exec();
}