Dialog::Dialog( QWidget *parent ) : QDialog( parent )
{
	//ui.setupUi( this );
	QLabel *Label1 = new QLabel( tr( "Label1" ) );
	QLabel *Label2 = new QLabel( tr( "Label2" ) );
	QLabel *Label3 = new QLabel( tr( "Label3" ) );

	QListWidget *list = new QListWidget( this );
	list->insertItem( 0, tr( "Window1" ) );
	list->insertItem( 1, tr( "Window2" ) );
	list->insertItem( 2, tr( "Window3" ) );

	QStackedWidget *stack = new QStackedWidget( this );
	stack->addWidget( Label1 );
	stack->addWidget( Label2 );
	stack->addWidget( Label3 );

	QHBoxLayout *Layout = new QHBoxLayout( this );
	Layout->setMargin( 5 );
	Layout->setSpacing( 5 );
	Layout->addWidget( list );
	Layout->addWidget( stack, 0, Qt::AlignHCenter );
	Layout->setStretchFactor( list, 1 );
	Layout->setStretchFactor( stack, 3 );
	connect( list, SIGNAL( currentRowChanged( int ) ), stack, SLOT( setCurrentIndex( int ) ) );
}
示例#2
0
void MainWindow::createStackedWidget()
{
    // List of all items in the left navigation bar
    QListWidget* lw = new QListWidget(this);
    lw->setFixedWidth(100);
    lw->setSelectionMode(QAbstractItemView::SingleSelection);
    QListWidgetItem* connectionItem = new QListWidgetItem;
    connectionItem->setText("Connexion");
    lw->insertItem(0,connectionItem);
    QListWidgetItem* curriculumItem = new QListWidgetItem;
    curriculumItem->setText("Mon parcours");
    lw->insertItem(1,curriculumItem);
    QListWidgetItem* expectationsItem = new QListWidgetItem;
    expectationsItem->setText("Prévisions");
    lw->insertItem(2,expectationsItem);
    QListWidgetItem* catalogItem = new QListWidgetItem;
    catalogItem->setText("Catalogue Uvs");
    lw->insertItem(3,catalogItem);
    QListWidgetItem* adminItem = new QListWidgetItem;
    adminItem->setText("Gestion Uvs");
    lw->insertItem(4,adminItem);

    // Create the pages
    admin_ = new Admin;
    catalog_ = new Catalog;
    curriculum_ = new Curriculum;
    expectations_ = new Expectations;
    connection_ = new Connection;

    // Link the pages with the vertical navigation bar
    navigationStackedWidget_ = new QStackedWidget;
    navigationStackedWidget_->addWidget(connection_);
    navigationStackedWidget_->addWidget(curriculum_);
    navigationStackedWidget_->addWidget(expectations_);
    navigationStackedWidget_->addWidget(catalog_);
    navigationStackedWidget_->addWidget(admin_);

    QHBoxLayout* mainLayout = new QHBoxLayout;
    mainLayout->addWidget(lw);
    mainLayout->addWidget(navigationStackedWidget_);

    QWidget* cw = new QWidget;
    cw->setLayout(mainLayout);
    setCentralWidget(cw);

    curriculum_->setEnabled(false);
    expectations_->setEnabled(false);

    QObject::connect(lw,SIGNAL(currentRowChanged(int)),this,SLOT(setTag(int)));
    QObject::connect(connection_,SIGNAL(connected()),expectations_,SLOT(updateExpComboBox()));
    QObject::connect(connection_,SIGNAL(connected()),curriculum_,SLOT(generationView()));
    QObject::connect(connection_,SIGNAL(connected()),this,SLOT(afterConnection()));
}
示例#3
0
void CQReportDefinition::btnDownClicked()
{
    QListWidget * pList = static_cast< QListWidget * >(mpReportSectionTab->currentPage());
    int i, imax, to, multipleSelection;

    QListWidgetItem * pMove;

    // Find the index of the first selected item.
    for (i = 0, imax = pList->count(), to = -1, multipleSelection = 0; i < imax; i++)
        if (pList->item(i)->isSelected())
        {
            if (multipleSelection == 0) to = i;

            multipleSelection++;
        }
        else if (multipleSelection > 0)
        {
            pMove = pList->takeItem(i);

            if (pMove)
            {
                pList->insertItem(to, pMove);

                multipleSelection = 0;
                mChanged = true;
            }
        }

    // Unselect things we can not move.
    for (i = pList->count() - multipleSelection, imax = pList->count(); i < imax; i++)
        pList->item(i)->setSelected(false);

    return;
}
示例#4
0
void KActionSelectorPrivate::buttonAddClicked()
{
  // move all selected items from available to selected listbox
  QList<QListWidgetItem *> list = availableListWidget->selectedItems();
  foreach (QListWidgetItem* item, list) {
    availableListWidget->takeItem( availableListWidget->row( item ) );
    selectedListWidget->insertItem( insertionIndex( selectedListWidget, selectedInsertionPolicy ), item );
    selectedListWidget->setCurrentItem( item );
    emit q->added( item );
  }
示例#5
0
void ItemOrderList::on_pushButtonDown_clicked()
{
    QListWidget *list = ui->listWidgetItems;
    const int row = list->currentRow();
    if (row < 0 || row == list->count() - 1)
        return;

    list->blockSignals(true);
    list->insertItem(row + 1, list->takeItem(row));
    list->setCurrentRow(row + 1);
    list->blockSignals(false);
}
示例#6
0
void ManageUserDirectories::moveUp() {
  QListWidget *list = listWidget();
  QList<QListWidgetItem *> selected = list->selectedItems();
  for (int i = 0; i < selected.size(); i++) {
    int index = list->row(selected[i]);
    if (index != 0) {
      QListWidgetItem *move = list->takeItem(index);
      list->insertItem(index - 1, move);
    }
    list->setCurrentItem(selected[i]);
  }
}
示例#7
0
void ItemOrderList::onPushButtonUpClicked()
{
    QListWidget *list = ui->listWidgetItems;
    const int row = list->currentRow();
    if (row < 1)
        return;

    list->blockSignals(true);
    list->insertItem(row - 1, list->takeItem(row));
    list->setCurrentRow(row - 1);
    list->blockSignals(false);
}
示例#8
0
void ItemOrderList::insertItem(const QString &label, bool checked, bool highlight, const QIcon &icon,
                               const ItemPtr &item, int targetRow)
{
    QListWidget *list = ui->listWidgetItems;
    QListWidgetItem *listItem = new QListWidgetItem(icon, label);
    const int row = targetRow >= 0 ? qMin(list->count(), targetRow) : list->count();
    list->insertItem(row, listItem);
    listItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
    setItemHighlight(listItem, highlight);

    m_items[listItem] = ItemWidgetPair(item);

    // Resize list to minimal size.
    const int w = list->sizeHintForColumn(0)
                + list->verticalScrollBar()->sizeHint().width() + 4;
    list->setMaximumWidth(w);

    if ( list->currentItem() == NULL )
        list->setCurrentRow(row);
}
示例#9
0
void SettingsWidget::moveModule()
{
	if (QToolButton *tB = qobject_cast<QToolButton *>(sender()))
	{
		const bool moveDown = tB->arrowType() == Qt::DownArrow;
		const int idx = tB->property("idx").toInt();
		QListWidget *mL = page2ModulesList[idx]->list;
		int row = mL->currentRow();
		if (row > -1)
		{
			QListWidgetItem *item = mL->takeItem(row);
			mL->clearSelection();
			if (moveDown)
				++row;
			else
				--row;
			mL->insertItem(row, item);
			mL->setCurrentItem(item);
		}
	}
}
示例#10
0
void ItemOrderList::insertItem(const QString &label, bool checked, const QIcon &icon,
                               const ItemPtr &item, int targetRow)
{
    QListWidget *list = ui->listWidgetItems;
    auto listItem = new QListWidgetItem(icon, label);
    listItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
    m_items[listItem] = ItemWidgetPair(item, checked);

    const int row = targetRow >= 0 ? qMin(list->count(), targetRow) : list->count();
    list->insertItem(row, listItem);

    // Resize list to minimal size.
    if ( !isVisible() ) {
        const int w = list->sizeHintForColumn(0)
                    + list->verticalScrollBar()->sizeHint().width() + 4;
        list->resize( w, list->height() );
    }

    if ( list->currentItem() == nullptr )
        list->setCurrentRow(row);
}
示例#11
0
void CQReportDefinition::btnUpClicked()
{
    QListWidget * pList = static_cast< QListWidget * >(mpReportSectionTab->currentPage());
    int i, to, multipleSelection;

    QListWidgetItem * pMove;

    for (i = pList->count() - 1, to = -1, multipleSelection = 0; i >= 0; i--)
        if (pList->item(i)->isSelected())
        {
            if (multipleSelection == 0)
            {
                to = i;
            }

            multipleSelection++;
        }
        else if (multipleSelection > 0)
        {
            pMove = pList->takeItem(i);

            if (pMove)
            {
                pList->insertItem(to, pMove);

                multipleSelection = 0;
                mChanged = true;
            }
        }

    // Unselect things we can not move.
    for (i = 0; i < multipleSelection; i++)
        pList->item(i)->setSelected(false);

    return;
}
示例#12
0
void KFFOpt_scenery::reloadScenarii( bool showMessage )
{
	QListWidget* selected = ui_widget.selector_scenarii->selectedListWidget();
	QListWidget* available = ui_widget.selector_scenarii->availableListWidget();
	QStringList::Iterator ite;
	QIcon icon;
	QStringList list;
	int i = 0;
	bool found;

	selected->clear();
	available->clear();
	m_scenarii.clear();
	getScenarii();


	QMapIterator<QString, KFFScenarioData> it( m_scenarii );

	list = Settings::scenarii_selected();

	while ( it.hasNext() )
	{
		found = false;
		it.next();

		if ( it.value().type == "aircraft" || it.value().type == "tanker" ||
		        it.value().type == "wingman" || it.value().type == "ballistic" )
		{
			icon.addPixmap( m_aircraftIcon );
		}
		else if ( it.value().type == "thunderstorm" || it.value().type == "thermal" )
		{
			icon.addPixmap( m_weatherIcon );
		}
		else if ( it.value().type == "ship" || it.value().type == "carrier" )
		{
			icon.addPixmap( m_shipIcon );
		}
		else if (it.value().type == "groundvehicle" )
		{
			icon.addPixmap( m_trainIcon );
		}
		else
		{
			icon.addPixmap( m_unknowIcon );
		}

		QListWidgetItem* item = new QListWidgetItem( icon, it.key() );
		item->setToolTip(it.value().description);

		ite = list.begin();

		while ( !found && ite != list.end() )
		{
			if ( it.key() == *ite )
			{
				found = true;
			}

			ite++;
		}

		if ( found )
		{
			selected->insertItem( i++, item );
		}
		else
		{
			available->insertItem( i++, item );
		}

	}

	//loadSettings();
	if ( showMessage )
	{
		KMessageBox::information( this, i18n( "Reloaded" ) );
	}
}
示例#13
0
文件: main.cpp 项目: ifhw/study
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    // QListWidget
    QListWidget listWidget;
    // 一种添加项目的简便方法
    new QListWidgetItem("a", &listWidget);
    // 添加项目的另一种方法,这样还可以进行各种设置
    QListWidgetItem *listWidgetItem = new QListWidgetItem;
    listWidgetItem->setText("b");
    listWidgetItem->setIcon(QIcon("../modelView2/yafeilinux.png"));
    listWidgetItem->setToolTip("this is b!");
    listWidget.insertItem(1, listWidgetItem);
    // 设置排序为倒序
    listWidget.sortItems(Qt::DescendingOrder);
    // 显示列表部件
    listWidget.show();

    // QTreeWidget
    QTreeWidget treeWidget;
    // 必须设置列数
    treeWidget.setColumnCount(2);
    // 设置标头
    QStringList headers;
    headers << "name" << "year";
    treeWidget.setHeaderLabels(headers);
    // 添加项目
    QTreeWidgetItem *grade1 = new QTreeWidgetItem(&treeWidget);
    grade1->setText(0,"Grade1");
    QTreeWidgetItem *student = new QTreeWidgetItem(grade1);
    student->setText(0,"Tom");
    student->setText(1,"1986");
    QTreeWidgetItem *grade2 = new QTreeWidgetItem(&treeWidget, grade1);
    grade2->setText(0,"Grade2");
    treeWidget.show();

    // QTableWidget
    // 创建表格部件,同时指定行数和列数
    QTableWidget tableWidget(3, 2);
    // 创建表格项目,并插入到指定单元
    QTableWidgetItem *tableWidgetItem = new QTableWidgetItem("qt");
    tableWidget.setItem(1, 1, tableWidgetItem);
    // 创建表格项目,并将它们作为标头
    QTableWidgetItem *headerV = new QTableWidgetItem("first");
    tableWidget.setVerticalHeaderItem(0,headerV);
    QTableWidgetItem *headerH = new QTableWidgetItem("ID");
    tableWidget.setHorizontalHeaderItem(0,headerH);
    tableWidget.show();

    // 为listWidget启用拖放
    // 设置选择模式为单选
    listWidget.setSelectionMode(QAbstractItemView::SingleSelection);
    // 启用拖动
    listWidget.setDragEnabled(true);
    // 设置接受拖放
    listWidget.viewport()->setAcceptDrops(true);
    // 设置显示将要被放置的位置
    listWidget.setDropIndicatorShown(true);
    // 设置拖放模式为移动项目,如果不设置,默认为复制项目
    listWidget.setDragDropMode(QAbstractItemView::InternalMove);

    return app.exec();
}