//---------------------FLOW FUNCTION ----------------------- QGroupBox * Mainwindow::viewadd(QWidget *centralwidget,QString filter) { QGroupBox *box = new QGroupBox(centralwidget); QVBoxLayout *layout = new QVBoxLayout; RoomView = new QTableView(); RoomView->setEditTriggers(QAbstractItemView::NoEditTriggers); RoomView->setSelectionBehavior(QAbstractItemView::SelectRows); RoomView->setSelectionMode(QAbstractItemView::SingleSelection); RoomView->hideColumn(4); RoomView->hideColumn(5); RoomView->setShowGrid(false); RoomView->verticalHeader()->hide(); RoomView->setAlternatingRowColors(true); if(filter.isEmpty()) { RoomView->setModel(modelback(centralwidget)); } else { RoomView->setModel(searchmodel(filter)); } QLocale locale = RoomView->locale(); locale.setNumberOptions(QLocale::OmitGroupSeparator); RoomView->setLocale(locale); layout->addWidget(RoomView,0,0); box->setLayout(layout); box->setGeometry(QRect(20, 55, 251, 261)); box->show(); return box; }
int main(int argc, char *argv[]) { QApplication app(argc, argv); //! [0] QFileInfo fileInfo1("~/examples/191697/."); QFileInfo fileInfo2("~/examples/191697/.."); QFileInfo fileInfo3("~/examples/191697/main.cpp"); //! [0] //! [1] QFileInfo fileInfo4("."); QFileInfo fileInfo5(".."); QFileInfo fileInfo6("main.cpp"); //! [1] qDebug() << fileInfo1.fileName(); qDebug() << fileInfo2.fileName(); qDebug() << fileInfo3.fileName(); qDebug() << fileInfo4.fileName(); qDebug() << fileInfo5.fileName(); qDebug() << fileInfo6.fileName(); QPushButton* button1 = new QPushButton(fileInfo1.dir().path()); QPushButton* button2 = new QPushButton(fileInfo2.dir().path()); QPushButton* button3 = new QPushButton(fileInfo3.dir().path()); QPushButton* button4 = new QPushButton(fileInfo4.dir().path()); QPushButton* button5 = new QPushButton(fileInfo5.dir().path()); QPushButton* button6 = new QPushButton(fileInfo6.dir().path()); QVBoxLayout* vbox = new QVBoxLayout; vbox->addWidget(button1); vbox->addWidget(button2); vbox->addWidget(button3); vbox->addWidget(button4); vbox->addWidget(button5); vbox->addWidget(button6); vbox->addStretch(1); QGroupBox *groupBox = new QGroupBox("QFileInfo::dir() test"); groupBox->setLayout(vbox); groupBox->show(); return app.exec(); }
ConfigGroupBox *ConfigTab::configGroupBox(const QString &name, bool create) { if (MyConfigGroupBoxes.contains(name)) return MyConfigGroupBoxes[name]; if (!create) return 0; QGroupBox *groupBox = new QGroupBox(name, MyMainWidget); QHBoxLayout *groupBoxLayout = new QHBoxLayout(groupBox); groupBoxLayout->setSizeConstraint(QLayout::SetMinimumSize); MyMainLayout->insertWidget(MyConfigGroupBoxes.count(), groupBox); ConfigGroupBox *newConfigGroupBox = new ConfigGroupBox(name, this, groupBox); MyConfigGroupBoxes[name] = newConfigGroupBox; groupBox->show(); return newConfigGroupBox; }
AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, PrefsItemData * data ) : QWidget( _parent ), p_intf( _p_intf ) { /* Find our module */ module_t *p_module = NULL; if( data->i_type == TYPE_CATEGORY ) return; else if( data->i_type == TYPE_MODULE ) p_module = module_find( data->psz_name ); else { p_module = module_get_main(); assert( p_module ); } unsigned confsize; module_config_t *const p_config = module_config_get (p_module, &confsize), *p_item = p_config, *p_end = p_config + confsize; if( data->i_type == TYPE_SUBCATEGORY || data->i_type == TYPE_CATSUBCAT ) { while (p_item < p_end) { if( p_item->i_type == CONFIG_SUBCATEGORY && ( ( data->i_type == TYPE_SUBCATEGORY && p_item->value.i == data->i_object_id ) || ( data->i_type == TYPE_CATSUBCAT && p_item->value.i == data->i_subcat_id ) ) ) break; p_item++; } } /* Widgets now */ global_layout = new QVBoxLayout(); global_layout->setMargin( 2 ); QString head; QString help; help = QString( data->help ); if( data->i_type == TYPE_SUBCATEGORY || data->i_type == TYPE_CATSUBCAT ) { head = QString( data->name ); p_item++; // Why that ? } else { head = QString( qtr( module_GetLongName( p_module ) ) ); } QLabel *titleLabel = new QLabel( head ); QFont titleFont = QApplication::font(); titleFont.setPointSize( titleFont.pointSize() + 6 ); titleLabel->setFont( titleFont ); // Title <hr> QFrame *title_line = new QFrame; title_line->setFrameShape(QFrame::HLine); title_line->setFrameShadow(QFrame::Sunken); QLabel *helpLabel = new QLabel( help, this ); helpLabel->setWordWrap( true ); global_layout->addWidget( titleLabel ); global_layout->addWidget( title_line ); global_layout->addWidget( helpLabel ); QGroupBox *box = NULL; QGridLayout *boxlayout = NULL; QScrollArea *scroller= new QScrollArea; scroller->setFrameStyle( QFrame::NoFrame ); QWidget *scrolled_area = new QWidget; QGridLayout *layout = new QGridLayout(); int i_line = 0, i_boxline = 0; bool has_hotkey = false; if( p_item ) do { if( ( ( data->i_type == TYPE_SUBCATEGORY && p_item->value.i != data->i_object_id ) || ( data->i_type == TYPE_CATSUBCAT && p_item->value.i != data->i_subcat_id ) ) && ( p_item->i_type == CONFIG_CATEGORY || p_item->i_type == CONFIG_SUBCATEGORY ) ) break; if( p_item->b_internal ) continue; if( p_item->i_type == CONFIG_SECTION ) { if( box ) { box->setLayout( boxlayout ); box->show(); layout->addWidget( box, i_line, 0, 1, -1 ); i_line++; } box = new QGroupBox( qtr( p_item->psz_text ), this ); box->hide(); boxlayout = new QGridLayout(); } /* Only one hotkey control */ if( p_item->i_type == CONFIG_ITEM_KEY ) { if( has_hotkey ) continue; has_hotkey = true; } ConfigControl *control; if( ! box ) control = ConfigControl::createControl( VLC_OBJECT( p_intf ), p_item, this, layout, i_line ); else control = ConfigControl::createControl( VLC_OBJECT( p_intf ), p_item, this, boxlayout, i_boxline ); if( !control ) continue; if( box ) i_boxline++; else i_line++; controls.append( control ); } while( !( ( data->i_type == TYPE_SUBCATEGORY || data->i_type == TYPE_CATSUBCAT ) && ( p_item->i_type == CONFIG_CATEGORY || p_item->i_type == CONFIG_SUBCATEGORY ) ) && ( ++p_item < p_end ) ); if( box && i_boxline > 0 ) { box->setLayout( boxlayout ); box->show(); layout->addWidget( box, i_line, 0, 1, -1 ); } scrolled_area->setSizePolicy( QSizePolicy::Preferred,QSizePolicy::Fixed ); scrolled_area->setLayout( layout ); scroller->setWidget( scrolled_area ); scroller->setWidgetResizable( true ); global_layout->addWidget( scroller ); setLayout( global_layout ); }
void GroupPageWidget::setupWidgets() { if ( m_widget_created ) return; QVBoxLayout *vLayout = new QVBoxLayout( this ); vLayout->setMargin( 6 ); vLayout->setSpacing( 3 ); struct uim_custom_group *group = uim_custom_group_get( m_group_sym.toLatin1().constData() ); if( group == 0 ) return; QLabel *groupLabel = new QLabel( _FU8(group->label), this ); groupLabel->setAlignment( Qt::AlignLeft ); vLayout->addWidget( groupLabel ); QFrame *separator = new QFrame( this ); separator->setFrameShape( QFrame::HLine ); separator->setFrameShadow( QFrame::Sunken ); vLayout->addWidget( separator ); /* default QVGroupBox */ QGroupBox *defaultGroupVBox = new QGroupBox( this ); vLayout->addWidget( defaultGroupVBox ); defaultGroupVBox->hide(); #if 0 SubgroupData *sd = new SubgroupData( this, group_name ); /* add various widgets to the vbox */ char **custom_syms = uim_custom_collect_by_group( group_name ); if( custom_syms ) { for( char **custom_sym = custom_syms; *custom_sym; custom_sym++ ) { QGroupBox *vbox = sd->searchGroupVBoxByCustomSym( *custom_sym ); if( vbox == 0 ) { vbox = defaultGroupVBox; vbox->show(); } UimCustomItemIface *iface = addCustom( vbox, *custom_sym ); if( iface ) m_customIfaceList.append( iface ); } uim_custom_symbol_list_free( custom_syms ); } #else char **sub_groups = uim_custom_group_subgroups( m_group_sym.toLatin1().constData() ); char **sgrp; for( sgrp = sub_groups; *sgrp; sgrp++ ) { struct uim_custom_group *sgroup_custom = uim_custom_group_get( *sgrp ); QGroupBox *vbox; if( QString::compare( *sgrp, "main" ) == 0 ) { vbox = defaultGroupVBox; vbox->show(); } else { vbox = new QGroupBox( _FU8(sgroup_custom->label), this ); vLayout->addWidget( vbox ); } QVBoxLayout *layout = new QVBoxLayout; vbox->setLayout( layout ); /* XXX quick hack to use AND expression of groups */ QString groups( m_group_sym ); groups += " '"; groups += *sgrp; char **custom_syms = uim_custom_collect_by_group( groups.toLatin1().constData() ); if( !custom_syms ) continue; for( char **custom_sym = custom_syms; *custom_sym; custom_sym++ ) { UimCustomItemIface *iface = addCustom( vbox, *custom_sym ); if( iface ) m_customIfaceList.append( iface ); } uim_custom_symbol_list_free( custom_syms ); uim_custom_group_free( sgroup_custom ); } uim_custom_symbol_list_free( sub_groups ); #endif /* free */ //delete sd; uim_custom_group_free( group ); /* bottom up */ vLayout->addStretch(); setLayout( vLayout ); m_widget_created = true; }