本文整理汇总了C++中QListWidget::setSelectionMode方法的典型用法代码示例。如果您正苦于以下问题:C++ QListWidget::setSelectionMode方法的具体用法?C++ QListWidget::setSelectionMode怎么用?C++ QListWidget::setSelectionMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListWidget
的用法示例。
在下文中一共展示了QListWidget::setSelectionMode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void ListBoxControl::update (int pId)
{
uicontrol::properties& up = properties<uicontrol> ();
QListWidget* list = qWidget<QListWidget> ();
switch (pId)
{
case uicontrol::properties::ID_STRING:
m_blockCallback = true;
list->clear ();
list->addItems (Utils::fromStringVector (up.get_string_vector ()));
updateSelection (list, up.get_value ().matrix_value ());
m_blockCallback = false;
break;
case uicontrol::properties::ID_MIN:
case uicontrol::properties::ID_MAX:
if ((up.get_max () - up.get_min ()) > 1)
list->setSelectionMode (QAbstractItemView::ExtendedSelection);
else
list->setSelectionMode (QAbstractItemView::SingleSelection);
break;
case uicontrol::properties::ID_VALUE:
m_blockCallback = true;
updateSelection (list, up.get_value ().matrix_value ());
m_blockCallback = false;
break;
default:
BaseControl::update (pId);
break;
}
}
示例2: QMenu
MainWindow::MainWindow()
{
QMenu *fileMenu = new QMenu(tr("&File"));
QAction *quitAction = fileMenu->addAction(tr("E&xit"));
quitAction->setShortcut(tr("Ctrl+Q"));
menuBar()->addMenu(fileMenu);
// For convenient quoting:
//! [0]
QListWidget *listWidget = new QListWidget(this);
listWidget->setSelectionMode(QAbstractItemView::SingleSelection);
listWidget->setDragEnabled(true);
listWidget->viewport()->setAcceptDrops(true);
listWidget->setDropIndicatorShown(true);
//! [0] //! [1]
listWidget->setDragDropMode(QAbstractItemView::InternalMove);
//! [1]
this->listWidget = listWidget;
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
setupListItems();
setCentralWidget(listWidget);
setWindowTitle(tr("List Widget"));
}
示例3: createView
void CMainWnd::createView(XMLConfig *pXMLConfig, const DOMNode *pNode) {
QWidget *pTab; QListWidget *pListWidget = 0;
pTab = new QWidget(m_pTabContainer);
pListWidget = new QListWidget(pTab);
pListWidget->setGeometry(QRect(5, 5, pXMLConfig->gattr("view:width").toUInt() - 32, pXMLConfig->gattr("view:height").toUInt() - 56));
pListWidget->setSelectionMode(QAbstractItemView::NoSelection);
pListWidget->setFont(QFont("courier new", 9));
m_pTabContainer->insertTab(0, pTab, pXMLConfig->attr(pNode, "caption"));
QString sTmp = pXMLConfig->attr(pNode, "id");
m_mViews[sTmp.right(sTmp.length() - 1).toUShort()] = pListWidget;
}
示例4: createStackedWidget
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()));
}
示例5: AddList
void cQFilterWindow::AddList( int iRow, const QString &iLabel, QString *iChoices, size_t iNumChoices, QGridLayout &iGrid )
/**********************************************************************/
{
iGrid.addWidget( new QLabel( iLabel ), iRow, 0 );
QListWidget *vChoices = new QListWidget();
vChoices->setSelectionMode( QAbstractItemView::MultiSelection );
// vChoices->setSortingEnabled( true );
// vChoices->addItem( "" );
for ( size_t i=0; i<iNumChoices; i++ )
{
vChoices->addItem( iChoices[ i ] );
}
iGrid.addWidget( vChoices, iRow, 1, 1, 2 );
connect( vChoices, SIGNAL( valueChanged(int) ), this, SLOT( OnValueChanged(int) ) );
}
示例6: CreateWidget
//.........这里部分代码省略.........
case EXTENSION_WIDGET_IMAGE:
label = new QLabel( this );
label->setPixmap( QPixmap( qfu( p_widget->psz_text ) ) );
if( p_widget->i_width > 0 )
label->setMaximumWidth( p_widget->i_width );
if( p_widget->i_height > 0 )
label->setMaximumHeight( p_widget->i_height );
label->setScaledContents( true );
p_widget->p_sys_intf = label;
return label;
case EXTENSION_WIDGET_HTML:
textArea = new QTextBrowser( this );
textArea->setOpenExternalLinks( true );
textArea->setHtml( qfu( p_widget->psz_text ) );
p_widget->p_sys_intf = textArea;
return textArea;
case EXTENSION_WIDGET_TEXT_FIELD:
textInput = new QLineEdit( this );
textInput->setText( qfu( p_widget->psz_text ) );
textInput->setReadOnly( false );
textInput->setEchoMode( QLineEdit::Normal );
inputMapper->setMapping( textInput, new WidgetMapper( p_widget ) );
/// @note: maybe it would be wiser to use textEdited here?
CONNECT( textInput, textChanged(const QString &),
inputMapper, map() );
p_widget->p_sys_intf = textInput;
return textInput;
case EXTENSION_WIDGET_PASSWORD:
textInput = new QLineEdit( this );
textInput->setText( qfu( p_widget->psz_text ) );
textInput->setReadOnly( false );
textInput->setEchoMode( QLineEdit::Password );
inputMapper->setMapping( textInput, new WidgetMapper( p_widget ) );
/// @note: maybe it would be wiser to use textEdited here?
CONNECT( textInput, textChanged(const QString &),
inputMapper, map() );
p_widget->p_sys_intf = textInput;
return textInput;
case EXTENSION_WIDGET_CHECK_BOX:
checkBox = new QCheckBox( this );
checkBox->setText( qfu( p_widget->psz_text ) );
checkBox->setChecked( p_widget->b_checked );
clickMapper->setMapping( checkBox, new WidgetMapper( p_widget ) );
CONNECT( checkBox, stateChanged( int ), clickMapper, map() );
p_widget->p_sys_intf = checkBox;
return checkBox;
case EXTENSION_WIDGET_DROPDOWN:
comboBox = new QComboBox( this );
comboBox->setEditable( false );
for( p_value = p_widget->p_values;
p_value != NULL;
p_value = p_value->p_next )
{
comboBox->addItem( qfu( p_value->psz_text ), p_value->i_id );
}
/* Set current item */
if( p_widget->psz_text )
{
int idx = comboBox->findText( qfu( p_widget->psz_text ) );
if( idx >= 0 )
comboBox->setCurrentIndex( idx );
}
selectMapper->setMapping( comboBox, new WidgetMapper( p_widget ) );
CONNECT( comboBox, currentIndexChanged( const QString& ),
selectMapper, map() );
return comboBox;
case EXTENSION_WIDGET_LIST:
list = new QListWidget( this );
list->setSelectionMode( QAbstractItemView::ExtendedSelection );
for( p_value = p_widget->p_values;
p_value != NULL;
p_value = p_value->p_next )
{
QListWidgetItem *item =
new QListWidgetItem( qfu( p_value->psz_text ) );
item->setData( Qt::UserRole, p_value->i_id );
list->addItem( item );
}
selectMapper->setMapping( list, new WidgetMapper( p_widget ) );
CONNECT( list, itemSelectionChanged(),
selectMapper, map() );
return list;
case EXTENSION_WIDGET_SPIN_ICON:
spinIcon = new SpinningIcon( this );
spinIcon->play( p_widget->i_spin_loops );
p_widget->p_sys_intf = spinIcon;
return spinIcon;
default:
msg_Err( p_intf, "Widget type %d unknown", p_widget->type );
return NULL;
}
}
示例7: main
int main (int argc, char** argv) {
// Handle input
float pointSize;
float pointStep;
float alpha;
int applyTransform;
int step;
string logFilename;
string configFilename;
float di_scaleFactor;
float scale;
g2o::CommandArgs arg;
arg.param("vz_pointSize", pointSize, 1.0f, "Size of the points where are visualized");
arg.param("vz_transform", applyTransform, 1, "Choose if you want to apply the absolute transform of the point clouds");
arg.param("vz_step", step, 1, "Visualize a point cloud each vz_step point clouds");
arg.param("vz_alpha", alpha, 1.0f, "Alpha channel value used for the color points");
arg.param("vz_pointStep", pointStep, 1, "Step at which point are drawn");
arg.param("vz_scale", scale, 2, "Depth image size reduction factor");
arg.param("di_scaleFactor", di_scaleFactor, 0.001f, "Scale factor to apply to convert depth images in meters");
arg.paramLeftOver("configFilename", configFilename, "", "Configuration filename", true);
arg.paramLeftOver("logFilename", logFilename, "", "Log filename", true);
arg.parseArgs(argc, argv);
// Create GUI
QApplication application(argc,argv);
QWidget *mainWindow = new QWidget();
mainWindow->setWindowTitle("pwn_tracker_log_viewer");
QHBoxLayout *hlayout = new QHBoxLayout();
mainWindow->setLayout(hlayout);
QVBoxLayout *vlayout = new QVBoxLayout();
hlayout->addItem(vlayout);
QVBoxLayout *vlayout2 = new QVBoxLayout();
hlayout->addItem(vlayout2);
hlayout->setStretch(1, 1);
QListWidget* listWidget = new QListWidget(mainWindow);
listWidget->setSelectionMode(QAbstractItemView::MultiSelection);
vlayout->addWidget(listWidget);
PWNQGLViewer* viewer = new PWNQGLViewer(mainWindow);
vlayout2->addWidget(viewer);
Eigen::Isometry3f T;
T.setIdentity();
T.matrix().row(3) << 0.0f, 0.0f, 0.0f, 1.0f;
// Read config file
cout << "Loading config file..." << endl;
Aligner *aligner;
DepthImageConverter *converter;
std::vector<Serializable*> instances = readConfig(aligner, converter, configFilename.c_str());
converter->projector()->scale(1.0f/scale);
cout << "... done" << endl;
// Read and parse log file
std::vector<boss::Serializable*> objects;
std::vector<PwnTrackerFrame*> trackerFrames;
std::vector<PwnTrackerRelation*> trackerRelations;
Deserializer des;
des.setFilePath(logFilename);
cout << "Loading log file..." << endl;
load(trackerFrames, trackerRelations, objects, des, step);
cout << "... done" << endl;
// Load the drawable list with the PwnTrackerFrame objects
std::vector<Frame*> pointClouds;
pointClouds.resize(trackerFrames.size());
Frame *dummyFrame = 0;
std::fill(pointClouds.begin(), pointClouds.end(), dummyFrame);
for(size_t i = 0; i < trackerFrames.size(); i++) {
PwnTrackerFrame *pwnTrackerFrame = trackerFrames[i];
char nummero[1024];
sprintf(nummero, "%05d", (int)i);
listWidget->addItem(QString(nummero));
QListWidgetItem *lastItem = listWidget->item(listWidget->count() - 1);
Isometry3f transform = Isometry3f::Identity();
if(applyTransform) {
isometry3d2f(transform, pwnTrackerFrame->transform());
transform = transform*pwnTrackerFrame->sensorOffset;
}
transform.matrix().row(3) << 0.0f, 0.0f, 0.0f, 1.0f;
GLParameterFrame *frameParams = new GLParameterFrame();
frameParams->setStep(pointStep);
frameParams->setShow(false);
DrawableFrame* drawableFrame = new DrawableFrame(transform, frameParams, pointClouds[i]);
viewer->addDrawable(drawableFrame);
}
// Manage GUI
viewer->init();
mainWindow->show();
viewer->show();
listWidget->show();
viewer->setAxisIsDrawn(true);
bool selectionChanged = false;
QListWidgetItem *item = 0;
DepthImage depthImage;
DepthImage scaledDepthImage;
while (mainWindow->isVisible()) {
//.........这里部分代码省略.........
示例8: main
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();
}
示例9: createWidgets
void LabelingWidgetQt::createWidgets() {
// resize(300,300);
QVBoxLayout* mainLayout = new QVBoxLayout;
tabWidget_ = new QTabWidget();
mainLayout->addWidget(tabWidget_);
QListWidget* heartCTList = new QListWidget();
heartCTList->setSelectionMode(QAbstractItemView::MultiSelection);
heartCTList->addItem("Columna vertebralis");
heartCTList->addItem("Aorta");
heartCTList->addItem("V. cava inferior");
heartCTList->addItem("V. cava superior");
heartCTList->addItem("Atrium dextrum");
heartCTList->addItem("Ventriculus sinister");
heartCTList->addItem("Ventriculus dexter");
heartCTList->addItem("Truncus pulmonalis");
heartCTList->addItem("A. pulmonalis sinistra");
heartCTList->addItem("A. pulmonalis dextra");
heartCTList->addItem("Atrium sinistrum");
heartCTList->addItem("V. pulmonales sinistrae");
heartCTList->addItem("V. pulmonales dextrae");
tabWidget_->addTab(heartCTList, "Heart CT");
listWidgets_.push_back(heartCTList);
QListWidget* bodyCTList = new QListWidget();
bodyCTList->setSelectionMode(QAbstractItemView::MultiSelection);
bodyCTList->addItem("Item1");
bodyCTList->addItem("Item2");
tabWidget_->addTab(bodyCTList, "Body CT");
listWidgets_.push_back(bodyCTList);
QListWidget* skullMRTList = new QListWidget();
skullMRTList->setSelectionMode(QAbstractItemView::MultiSelection);
skullMRTList->addItem("Item1");
skullMRTList->addItem("Item2");
tabWidget_->addTab(skullMRTList, "Skull MRT");
listWidgets_.push_back(skullMRTList);
QListWidget* handCTList = new QListWidget();
handCTList->setSelectionMode(QAbstractItemView::MultiSelection);
handCTList->addItem("Item1");
handCTList->addItem("Item2");
tabWidget_->addTab(handCTList, "Hand CT");
listWidgets_.push_back(handCTList);
QHBoxLayout* hboxLayout1 = new QHBoxLayout();
hboxLayout1->addWidget(new QPushButton("Add All"));
hboxLayout1->addWidget(new QPushButton("Remove All"));
mainLayout->addItem(hboxLayout1);
QFrame* separator = new QFrame();
separator->setFrameShape(QFrame::HLine);
separator->setFrameShadow(QFrame::Sunken);
mainLayout->addWidget(separator);
QHBoxLayout* hboxLayout2 = new QHBoxLayout();
hboxLayout2->addWidget(new QPushButton("New Label"));
hboxLayout2->addWidget(new QPushButton("Edit Label"));
hboxLayout2->addWidget(new QPushButton("Delete Label"));
mainLayout->addItem(hboxLayout2);
setLayout(mainLayout);
}
示例10: QLabel
FinderHomeWidget::FinderHomeWidget(QWidget *parent) : QWidget(parent) {
setWindowTitle(tr("Home"));
// speedup painting since we'll paint the whole background
// by ourselves anyway in paintEvent()
setAttribute(Qt::WA_OpaquePaintEvent);
// colors
QPalette p = palette();
p.setBrush(QPalette::Base, Qt::black);
p.setColor(QPalette::Text, QColor(Qt::white));
p.setBrush(QPalette::Window, Qt::black);
p.setColor(QPalette::WindowText, QColor(Qt::white));
this->setPalette(p);
QBoxLayout *layout = new QVBoxLayout(this);
layout->setMargin(0);
layout->setSpacing(0);
layout->setAlignment(Qt::AlignLeft | Qt::AlignTop);
QLabel *welcomeLabel =
new QLabel("<h3>" +
tr("Welcome to <a href='%1'>%2</a>,")
.replace("<a ", "<a style='color:white'")
.arg(Constants::WEBSITE, Constants::APP_NAME)
+ "</h3>" + tr("Use the icons below to explore your music collection."), this);
welcomeLabel->setOpenExternalLinks(true);
welcomeLabel->setMargin(15);
layout->addWidget(welcomeLabel);
// welcomeLabel->setStyleSheet("background: qlineargradient(x1:0, y1:0, x2:1, y2:1,stop:0 #1a1a1a, stop:1 #343434)");
QListWidget *items = new QListWidget(this);
connect(items, SIGNAL(itemActivated(QListWidgetItem*)), SLOT(itemActivated(QListWidgetItem*)));
items->setAutoFillBackground(false);
items->setAttribute(Qt::WA_NoSystemBackground);
items->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
items->setFrameShape(QFrame::NoFrame);
items->setAttribute(Qt::WA_MacShowFocusRect, false);
items->setSelectionMode(QAbstractItemView::NoSelection);
items->addItem(tr("Artists"));
items->addItem(tr("Albums"));
items->addItem(tr("Tracks"));
items->addItem(tr("Years"));
items->addItem(tr("Languages"));
layout->addWidget(items);
/*
Artists
Albums
Tracks
Time machine
By language
Files
---
Tagcloud
*/
}