当前位置: 首页>>代码示例>>C++>>正文


C++ QTreeView::selectionModel方法代码示例

本文整理汇总了C++中QTreeView::selectionModel方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeView::selectionModel方法的具体用法?C++ QTreeView::selectionModel怎么用?C++ QTreeView::selectionModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTreeView的用法示例。


在下文中一共展示了QTreeView::selectionModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QDirModel model;

    QTreeView tree;
    QListView list;
    QTableView table;

    tree.setModel(&model);
    list.setModel(&model);
    table.setModel(&model);

    tree.setSelectionMode(QAbstractItemView::MultiSelection);
    list.setSelectionModel(tree.selectionModel());
    table.setSelectionModel(tree.selectionModel());

    QObject::connect(&tree,SIGNAL(doubleClicked(QModelIndex)),&list,SLOT(setRootIndex(QModelIndex)));
    QObject::connect(&tree,SIGNAL(doubleClicked(QModelIndex)),&table,SLOT(setRootIndex(QModelIndex)));

    QSplitter *splitter = new QSplitter;
    splitter->addWidget(&tree);
    splitter->addWidget(&list);
    splitter->addWidget(&table);
    splitter->setWindowTitle(QObject::tr("Model/View"));
    splitter->show();
    
    return a.exec();
}
开发者ID:Pengfei-Gao,项目名称:develop-reference-data,代码行数:30,代码来源:main.cpp

示例2: main

int main( int argc, char **argv )
{
    QApplication app( argc, argv );

    QTreeView *tree = new QTreeView();
    QListView *list = new QListView();
    QTableView *table = new QTableView();

    QSplitter splitter;
    splitter.addWidget(tree);
    splitter.addWidget(list);
    splitter.addWidget(table);

    QStandardItemModel model( 5, 2 );

    for( int r=0; r<5; r++ )
    {
        for( int c=0; c<2; c++)
        {
            QStandardItem *item = new QStandardItem(QString("Row:%0, Column:%1").arg(r).arg(c));

            if(c == 0)
            {
                for(int i=0; i<3; i++)
                {
                    QStandardItem *child = new QStandardItem(QString("Item %0").arg(i));
                    child->setEditable(false);
                    item->appendRow(child);
                }
            }

            model.setItem(r, c, item);
        }
    }

    model.setHorizontalHeaderItem(0, new QStandardItem("Foo"));
    model.setHorizontalHeaderItem(1, new QStandardItem("Bar-Baz"));

    tree->setModel(&model);
    list->setModel(&model);
    table->setModel(&model);

    list->setSelectionModel(tree->selectionModel());
    table->setSelectionModel(tree->selectionModel());

    table->setSelectionBehavior(QAbstractItemView::SelectRows);
    table->setSelectionMode(QAbstractItemView::SingleSelection);

    splitter.show();

    MainWindow w;
    w.show();

    return app.exec();
}
开发者ID:GLDsuh-a,项目名称:qt-1,代码行数:55,代码来源:main.cpp

示例3: QObject

ctkDICOMHostMainLogic::ctkDICOMHostMainLogic(ctkHostedAppPlaceholderWidget* placeHolder, ctkDICOMAppWidget* dicomAppWidget, 
                                             QWidget* placeHolderForControls) : 
  QObject(placeHolder), 
  PlaceHolderForHostedApp(placeHolder),
  DicomAppWidget(dicomAppWidget),
  PlaceHolderForControls(placeHolderForControls),
  ValidSelection(false),
  SendData(false)
{
  this->Host = new ctkExampleDicomHost(PlaceHolderForHostedApp);
  this->HostControls = new ctkExampleHostControlWidget(Host, PlaceHolderForControls);

  Data = new ctkDicomAppHosting::AvailableData;

  disconnect(this->Host,SIGNAL(startProgress()),this->Host,SLOT(onStartProgress()));
  connect(this->Host,SIGNAL(appReady()),this,SLOT(onAppReady()), Qt::QueuedConnection);
  connect(this->Host,SIGNAL(startProgress()),this,SLOT(publishSelectedData()), Qt::QueuedConnection);
  connect(this->PlaceHolderForHostedApp,SIGNAL(resized()),this,SLOT(placeHolderResized()));

  QTreeView * treeview = dicomAppWidget->findChild<QTreeView*>("TreeView");
  QItemSelectionModel* selectionmodel = treeview->selectionModel();
  connect(selectionmodel, SIGNAL(selectionChanged ( const QItemSelection &, const QItemSelection & )),
    this, SLOT(onTreeSelectionChanged(const QItemSelection &, const QItemSelection &)));

  connect(this->Host, SIGNAL(dataAvailable()), this, SLOT(onDataAvailable()));

  connect( qApp, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()) );
}
开发者ID:151706061,项目名称:CTK,代码行数:28,代码来源:ctkDICOMHostMainLogic.cpp

示例4: QWidget

LessThanWidget::LessThanWidget(QWidget* parent, Qt::WindowFlags f)
    : QWidget(parent, f)
{
  QLabel *explanation = new QLabel(this);
  explanation->setText("The yellow items are 'less than' the selected item according to QModelIndex::operator<().\n"
                       "The red items are greater than the selected item (i.e, not less than and not equal).");

  m_coloredTreeModel = new ColoredTreeModel(this);
  QTreeView *treeView = new QTreeView(this);
  treeView->setModel(m_coloredTreeModel);
  treeView->setSelectionBehavior(QAbstractItemView::SelectItems);
  treeView->setSelectionMode(QTreeView::SingleSelection);

  m_coloredTreeModel->setSelectionModel(treeView->selectionModel());

  QVBoxLayout *layout = new QVBoxLayout(this);
  layout->addWidget(explanation);
  layout->addWidget(treeView);

  insertGrid(QList<int>());
  insertGrid(QList<int>() << 2);
  insertGrid(QList<int>() << 3);
  insertGrid(QList<int>() << 4);
  insertGrid(QList<int>() << 3 << 2);
  insertGrid(QList<int>() << 3 << 3);
  insertGrid(QList<int>() << 3 << 4);
}
开发者ID:vasi,项目名称:kdelibs,代码行数:27,代码来源:lessthanwidget.cpp

示例5: QWidget

GraphViewer::GraphViewer(ProbeInterface *probe, QWidget *parent)
    : QWidget(parent),
      mWidget(new GraphWidget(this)),
      mProbeIface(probe)
{
    QSortFilterProxyModel *objectFilter = new KRecursiveFilterProxyModel(this);
    objectFilter->setSourceModel(probe->objectTreeModel());
    objectFilter->setDynamicSortFilter(true);

    QVBoxLayout *vbox = new QVBoxLayout;
    KFilterProxySearchLine *objectSearchLine = new KFilterProxySearchLine(this);
    objectSearchLine->setProxy(objectFilter);
    vbox->addWidget(objectSearchLine);
    QTreeView *objectTreeView = new QTreeView(this);
    objectTreeView->setModel(objectFilter);
    objectTreeView->setSortingEnabled(true);
    vbox->addWidget(objectTreeView);
    connect(objectTreeView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
            SLOT(handleRowChanged(QModelIndex)));
    mObjectTreeView = objectTreeView;

    QWidget *treeViewWidget = new QWidget(this);
    treeViewWidget->setLayout(vbox);

    QSplitter *splitter = new QSplitter(this);
    splitter->addWidget(treeViewWidget);
    splitter->addWidget(mWidget);
    QHBoxLayout *hbox = new QHBoxLayout(this);
    hbox->addWidget(splitter);

    QMetaObject::invokeMethod(this, "delayedInit", Qt::QueuedConnection);
}
开发者ID:frankosterfeld,项目名称:GammaRay,代码行数:32,代码来源:objectvisualizer.cpp

示例6: QDesignerObjectInspector

// ------------ ObjectInspector
ObjectInspector::ObjectInspector(QDesignerFormEditorInterface *core, QWidget *parent) :
    QDesignerObjectInspector(parent),
    m_impl(new ObjectInspectorPrivate(core))
{
    QVBoxLayout *vbox = new QVBoxLayout(this);
    vbox->setMargin(0);

    QTreeView *treeView = m_impl->treeView();
    vbox->addWidget(treeView);

    connect(treeView, SIGNAL(customContextMenuRequested(QPoint)),
            this, SLOT(slotPopupContextMenu(QPoint)));

    connect(treeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
            this, SLOT(slotSelectionChanged(QItemSelection,QItemSelection)));

    connect(treeView->header(), SIGNAL(sectionDoubleClicked(int)), this, SLOT(slotHeaderDoubleClicked(int)));
    setAcceptDrops(true);

    ItemViewFindWidget *findWidget = m_impl->findWidget();
    vbox->addWidget(findWidget);

    findWidget->setItemView(treeView);
    QAction *findAction = new QAction(
            ItemViewFindWidget::findIconSet(),
            tr("&Find in Text..."),
            this);
    findAction->setShortcut(QKeySequence::Find);
    findAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    addAction(findAction);
    connect(findAction, SIGNAL(triggered(bool)), findWidget, SLOT(activate()));
}
开发者ID:Fale,项目名称:qtmoko,代码行数:33,代码来源:objectinspector.cpp

示例7: updateActions

void TabWidget::updateActions()
{
    QTreeView *view = m_ui->treeView;
    bool hasSelection = !view->selectionModel()->selection().isEmpty();
    //removeRowAction->setEnabled(hasSelection);
    //removeColumnAction->setEnabled(hasSelection);

    bool hasCurrent = view->selectionModel()->currentIndex().isValid();
    //insertRowAction->setEnabled(hasCurrent);
    //insertColumnAction->setEnabled(hasCurrent);

    if (hasCurrent) {
        view->closePersistentEditor(view->selectionModel()->currentIndex());

        int row = view->selectionModel()->currentIndex().row();
        int column = view->selectionModel()->currentIndex().column();
    }

}
开发者ID:Ejik,项目名称:Life-organizer,代码行数:19,代码来源:tabwidget.cpp

示例8: GetSelectedCert

	QSslCertificate ManagerDialog::GetSelectedCert (CertPart part) const
	{
		QTreeView *view = nullptr;
		switch (part)
		{
		case CertPart::System:
			view = Ui_.SystemTree_;
			break;
		case CertPart::Local:
			view = Ui_.LocalTree_;
			break;
		}

		if (!view)
			return {};

		const auto& selected = view->selectionModel ()->selectedRows ();
		return selected.value (0).data (CertsModel::CertificateRole).value<QSslCertificate> ();
	}
开发者ID:mirok0,项目名称:leechcraft,代码行数:19,代码来源:managerdialog.cpp

示例9: Test_FileSystem_MVC

void Test_FileSystem_MVC()
{
	QSplitter* splitter = new QSplitter;//two widget
	QFileSystemModel* model = new QFileSystemModel;
	QTreeView* tree = new QTreeView(splitter);//left tree view
	QListView* list = new QListView(splitter);//right list view

	splitter->setWindowTitle("Two vies onto the same file system model");

	model->setRootPath(QDir::currentPath());
	tree->setModel(model);//set model for view
	tree->setRootIndex(model->index(QDir::currentPath()));

	list->setModel(model);
	list->setRootIndex(model->index(QDir::currentPath()));

	list->setSelectionModel(tree->selectionModel());
	splitter->show();

}
开发者ID:shenglonglinapple,项目名称:slin_code,代码行数:20,代码来源:BooleanMode.cpp

示例10: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    qRegisterMetaType<Error>();

    ThreadedParser parser;

    Memcheck::MemcheckRunner runner;
    runner.setValgrindExecutable(fakeValgrindExecutable());
    runner.setValgrindArguments(QStringList() << QLatin1String("-i") << dataFile(QLatin1String("memcheck-output-sample1.xml")) );
    runner.setParser(&parser);

    ModelDemo demo(&runner);
    QObject::connect(&runner, &ValgrindRunner::finished,
                     &demo, &ModelDemo::finished);
    ErrorListModel model;
    QObject::connect(&parser, &ThreadedParser::error,
                     &model, &ErrorListModel::addError,
                     Qt::QueuedConnection);

    QTreeView errorview;
    errorview.setSelectionMode(QAbstractItemView::SingleSelection);
    errorview.setSelectionBehavior(QAbstractItemView::SelectRows);
    errorview.setModel(&model);
    errorview.show();

    StackModel stackModel;
    demo.stackModel = &stackModel;

    QTreeView stackView;
    stackView.setModel(&stackModel);
    stackView.show();

    QObject::connect(errorview.selectionModel(), &QItemSelectionModel::selectionChanged,
                     &demo, &ModelDemo::selectionChanged);


    runner.start();

    return app.exec();
}
开发者ID:DuinoDu,项目名称:qt-creator,代码行数:41,代码来源:modeldemo.cpp

示例11: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    qRegisterMetaType<Valgrind::XmlProtocol::Error>();

    ThreadedParser parser;

    Valgrind::Memcheck::MemcheckRunner runner;
    runner.setValgrindExecutable(fakeValgrindExecutable());
    runner.setValgrindArguments(QStringList() << QLatin1String("-i") << dataFile(QLatin1String("memcheck-output-sample1.xml")) );
    runner.setParser(&parser);

    ModelDemo demo(&runner);
    runner.connect(&runner, SIGNAL(finished()), &demo, SLOT(finished()));
    ErrorListModel model;
    parser.connect(&parser, SIGNAL(error(Valgrind::XmlProtocol::Error)),
                   &model, SLOT(addError(Valgrind::XmlProtocol::Error)),
                   Qt::QueuedConnection);

    QTreeView errorview;
    errorview.setSelectionMode(QAbstractItemView::SingleSelection);
    errorview.setSelectionBehavior(QAbstractItemView::SelectRows);
    errorview.setModel(&model);
    errorview.show();

    StackModel stackModel;
    demo.stackModel = &stackModel;

    QTreeView stackView;
    stackView.setModel(&stackModel);
    stackView.show();

    errorview.connect(errorview.selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
                      &demo, SLOT(selectionChanged(QItemSelection,QItemSelection)));


    runner.start();

    return app.exec();
}
开发者ID:FlavioFalcao,项目名称:qt-creator,代码行数:40,代码来源:modeldemo.cpp

示例12: loadPlaylists

void MainWindow::loadPlaylists()
{
    QTreeView *playlists = (QTreeView*)ui->tvPlaylists;

    QStandardItemModel *model = new QStandardItemModel(3,1);
    QStandardItem *item = new QStandardItem(QString(tr("Search")));
    item->setData(DATA_SEARCH, DATA_KEY_PLAYLIST);
    item->setEditable(false);
    model->setItem(0, 0, item);
    item = new QStandardItem(QString(tr("History")));
    item->setData(DATA_HISTORY, DATA_KEY_PLAYLIST);
    item->setEditable(false);
    model->setItem(1, 0, item);
    item = new QStandardItem(QString(tr("Playlists")));
    item->setData(DATA_EMPTY, DATA_KEY_PLAYLIST);
    item->setEditable(false);
    QList<Playlist> pls = dp->getPlaylists();
    int n = pls.count();
    for( int i=0; i<n; i++ )
    {
      QStandardItem *child = new QStandardItem(pls[i].title);
      child->setData(pls[i].id, DATA_KEY_PLAYLIST);
      child->setEditable(false);
      item->appendRow(child);
    }
    model->setItem(2, 0, item);
    model->setHorizontalHeaderItem( 0, new QStandardItem(tr("Library")));
    model->horizontalHeaderItem(0)->setEditable(false);
    model->horizontalHeaderItem(0)->setEnabled(false);

    playlists->setModel(model);
    playlists->setContextMenuPolicy(Qt::CustomContextMenu);

    QModelIndexList indexes = model->match(model->index(2,0), Qt::DisplayRole, "*", -1, Qt::MatchWildcard|Qt::MatchRecursive);
    playlists->expand(indexes[0]);

    connect(playlists->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(loadPlaylist()));
}
开发者ID:victorkifer,项目名称:VKAudioPlayer,代码行数:38,代码来源:mainwindow.cpp

示例13: testGlobalSearch

void TestGlobalSearch::testGlobalSearch()
{
    QString filename(QFile::decodeName(FILES_DATA_DIR "/TestGlobalSearch.kexi"));
    kDebug() << filename;
    NewArgs args(m_argv);
    args.vals[args.count - 1] = qstrdup(QFile::encodeName(filename).constData());

    KexiAboutData aboutData;
    aboutData.setProgramName(ki18n(metaObject()->className()));
    int result = KexiMainWindow::create(args.count, args.vals, aboutData);
    QVERIFY(kapp);
    QCOMPARE(result, 0);

    QLineEdit *lineEdit = kexiTester().widget<QLineEdit*>("globalSearch.lineEdit");
    QVERIFY(lineEdit);
    QTreeView *treeView = kexiTester().widget<QTreeView*>("globalSearch.treeView");
    QVERIFY(treeView);

    lineEdit->setFocus();
    // enter "cars", expect 4 completion items
    QTest::keyClicks(lineEdit, "cars");
    QVERIFY(treeView->isVisible());
    int globalSearchCompletionListRows = treeView->model()->rowCount();
    QCOMPARE(globalSearchCompletionListRows, 4);

    // add "x", expect no completion items and hidden list
    QTest::keyClicks(lineEdit, "x");
    QVERIFY(!treeView->isVisible());
    globalSearchCompletionListRows = treeView->model()->rowCount();
    QCOMPARE(globalSearchCompletionListRows, 0);

    // Escape should clear
    QTest::keyClick(lineEdit, Qt::Key_Escape,  Qt::NoModifier, GUI_DELAY);
    QVERIFY(lineEdit->text().isEmpty());

    QTest::keyClicks(lineEdit, "cars");
    QVERIFY(treeView->isVisible());
    treeView->setFocus();
    QTest::keyPress(treeView, Qt::Key_Down, Qt::NoModifier, GUI_DELAY);
    QTest::keyPress(treeView, Qt::Key_Down, Qt::NoModifier, GUI_DELAY);
    QTest::keyPress(treeView, Qt::Key_Down, Qt::NoModifier, GUI_DELAY);

    // 3rd row should be "cars" form
    QModelIndexList selectedIndices = treeView->selectionModel()->selectedRows();
    QCOMPARE(selectedIndices.count(), 1);
    QCOMPARE(treeView->model()->data(selectedIndices.first(), Qt::DisplayRole).toString(), QLatin1String("cars"));

    // check if proper entry of Project Navigator is selected
    QTest::keyPress(treeView, Qt::Key_Enter, Qt::NoModifier, GUI_DELAY);

    KexiProjectNavigator *projectNavigator = kexiTester().widget<KexiProjectNavigator*>("KexiProjectNavigator");
    QVERIFY(projectNavigator);
    KexiPart::Item* selectedPartItem = projectNavigator->selectedPartItem();
    QVERIFY(selectedPartItem);
    QCOMPARE(selectedPartItem->name(), QLatin1String("cars"));
    QCOMPARE(selectedPartItem->partClass(), QLatin1String("org.kexi-project.form"));

    if (m_goToEventLoop) {
        result = qApp->exec();
        QCOMPARE(result, 0);
    }
}
开发者ID:crayonink,项目名称:calligra-2,代码行数:62,代码来源:TestGlobalSearch.cpp

示例14: QDialog

DlgCreateToken::DlgCreateToken(const QStringList &_predefinedTokens, QWidget *parent)
	: QDialog(parent), predefinedTokens(_predefinedTokens)
{
	nameLabel = new QLabel(tr("&Name:"));
	nameEdit = new QLineEdit(tr("Token"));
	nameEdit->selectAll();
	nameLabel->setBuddy(nameEdit);

	colorLabel = new QLabel(tr("C&olor:"));
	colorEdit = new QComboBox;
	colorEdit->addItem(tr("white"), "w");
	colorEdit->addItem(tr("blue"), "u");
	colorEdit->addItem(tr("black"), "b");
	colorEdit->addItem(tr("red"), "r");
	colorEdit->addItem(tr("green"), "g");
	colorEdit->addItem(tr("multicolor"), "m");
	colorEdit->addItem(tr("colorless"), QString());
	colorLabel->setBuddy(colorEdit);

	ptLabel = new QLabel(tr("&P/T:"));
	ptEdit = new QLineEdit;
	ptLabel->setBuddy(ptEdit);

	annotationLabel = new QLabel(tr("&Annotation:"));
	annotationEdit = new QLineEdit;
	annotationLabel->setBuddy(annotationEdit);
	
	destroyCheckBox = new QCheckBox(tr("&Destroy token when it leaves the table"));
	destroyCheckBox->setChecked(true);

	QGridLayout *grid = new QGridLayout;
	grid->addWidget(nameLabel, 0, 0);
	grid->addWidget(nameEdit, 0, 1);
	grid->addWidget(colorLabel, 1, 0);
	grid->addWidget(colorEdit, 1, 1);
	grid->addWidget(ptLabel, 2, 0);
	grid->addWidget(ptEdit, 2, 1);
	grid->addWidget(annotationLabel, 3, 0);
	grid->addWidget(annotationEdit, 3, 1);
	grid->addWidget(destroyCheckBox, 4, 0, 1, 2);
	
	QGroupBox *tokenDataGroupBox = new QGroupBox(tr("Token data"));
	tokenDataGroupBox->setLayout(grid);
	
	cardDatabaseModel = new CardDatabaseModel(db, this);
	cardDatabaseDisplayModel = new CardDatabaseDisplayModel(this);
	cardDatabaseDisplayModel->setSourceModel(cardDatabaseModel);
	cardDatabaseDisplayModel->setIsToken(CardDatabaseDisplayModel::ShowTrue);
	
	chooseTokenFromAllRadioButton = new QRadioButton(tr("Show &all tokens"));
	connect(chooseTokenFromAllRadioButton, SIGNAL(toggled(bool)), this, SLOT(actChooseTokenFromAll(bool)));
	chooseTokenFromDeckRadioButton = new QRadioButton(tr("Show tokens from this &deck"));
	connect(chooseTokenFromDeckRadioButton, SIGNAL(toggled(bool)), this, SLOT(actChooseTokenFromDeck(bool)));
	QTreeView *chooseTokenView = new QTreeView;
	chooseTokenView->setModel(cardDatabaseDisplayModel);
	chooseTokenView->setUniformRowHeights(true);
	chooseTokenView->setRootIsDecorated(false);
	chooseTokenView->setAlternatingRowColors(true);
	chooseTokenView->setSortingEnabled(true);
	chooseTokenView->sortByColumn(0, Qt::AscendingOrder);
	chooseTokenView->resizeColumnToContents(0);
	chooseTokenView->header()->setStretchLastSection(false);
	chooseTokenView->header()->hideSection(1);
	chooseTokenView->header()->hideSection(2);
	chooseTokenView->header()->setResizeMode(3, QHeaderView::ResizeToContents);
	chooseTokenView->header()->setResizeMode(4, QHeaderView::ResizeToContents);
	connect(chooseTokenView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), this, SLOT(tokenSelectionChanged(QModelIndex, QModelIndex)));
	
	if (predefinedTokens.isEmpty())
		chooseTokenFromAllRadioButton->setChecked(true);
	else {
		chooseTokenFromDeckRadioButton->setChecked(true);
		cardDatabaseDisplayModel->setCardNameSet(QSet<QString>::fromList(predefinedTokens));
	}
	
	QVBoxLayout *tokenChooseLayout = new QVBoxLayout;
	tokenChooseLayout->addWidget(chooseTokenFromAllRadioButton);
	tokenChooseLayout->addWidget(chooseTokenFromDeckRadioButton);
	tokenChooseLayout->addWidget(chooseTokenView);
	
	QGroupBox *tokenChooseGroupBox = new QGroupBox(tr("Choose token from list"));
	tokenChooseGroupBox->setLayout(tokenChooseLayout);
	
	QVBoxLayout *leftVBox = new QVBoxLayout;
	leftVBox->addWidget(tokenDataGroupBox);
	leftVBox->addStretch();
	
	QHBoxLayout *hbox = new QHBoxLayout;
	hbox->addLayout(leftVBox);
	hbox->addWidget(tokenChooseGroupBox);
	
	QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
	connect(buttonBox, SIGNAL(accepted()), this, SLOT(actOk()));
	connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
	
	QVBoxLayout *mainLayout = new QVBoxLayout;
	mainLayout->addLayout(hbox);
	mainLayout->addWidget(buttonBox);
	setLayout(mainLayout);

//.........这里部分代码省略.........
开发者ID:Arkham,项目名称:Cockatrice,代码行数:101,代码来源:dlg_create_token.cpp

示例15: QFileDialog

MultiQFileDialog::MultiQFileDialog(QWidget *parent, const QString &caption, const QString &directory, bool multiSelect, const QString &filter)
    : QFileDialog(parent, caption, directory, filter)
{
    this->showHidden = false;
    this->multiSelect = multiSelect;
    setOption(QFileDialog::DontUseNativeDialog, false);

    if (multiSelect)
    {
        setOption(QFileDialog::DontUseNativeDialog, true);
        le = findChild<QLineEdit*>(QString::fromUtf8("fileNameEdit"));

        QListView *l = findChild<QListView*>(QString::fromUtf8("listView"));
        if (l)
        {
            l->setSelectionMode(QListView::ExtendedSelection);
            if (le)
            {
                connect(l->selectionModel(),
                        SIGNAL(selectionChanged ( const QItemSelection &, const QItemSelection & )),
                        this,
                        SLOT(onSelectionChanged ( const QItemSelection &, const QItemSelection & )));
            }
        }

        QTreeView *t = findChild<QTreeView*>();
        if (t)
        {
            t->setSelectionMode(QAbstractItemView::ExtendedSelection);
            if (le)
            {
                connect(t->selectionModel(),
                        SIGNAL(selectionChanged ( const QItemSelection &, const QItemSelection & )),
                        this,
                        SLOT(onSelectionChanged ( const QItemSelection &, const QItemSelection & )));
            }
        }

        QLabel *label = findChild<QLabel*>(QString::fromUtf8("fileNameLabel"));
        if (label)
        {
            label->hide();
        }

        label = findChild<QLabel*>(QString::fromUtf8("fileTypeLabel"));
        if (label)
        {
            label->hide();
        }

        label = findChild<QLabel*>(QString::fromUtf8("lookInLabel"));
        if (label)
        {
            label->hide();
        }

        QDialogButtonBox *buttonBox = findChild<QDialogButtonBox*>(QString::fromUtf8("buttonBox"));
        if (buttonBox)
        {
            buttonBox->button(QDialogButtonBox::Open)->setText(QCoreApplication::translate("QDialogButtonBox", "&OK"));
        }

        setFileMode(QFileDialog::ExistingFiles);
        if (le)
        {
            le->setText(QCoreApplication::translate("ShellExtension", "Upload to MEGA"));
        }
    }

    QList<QWidget *> widgets = findChildren<QWidget *>();
    for (QList<QWidget *>::const_iterator it = widgets.begin(); it != widgets.end(); ++it)
    {
       (*it)->installEventFilter(this);
    }
    installEventFilter(this);
}
开发者ID:Avin15,项目名称:MEGAsync,代码行数:76,代码来源:MultiQFileDialog.cpp


注:本文中的QTreeView::selectionModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。