bool TreeWidgetColumnStretcher::eventFilter(QObject *obj, QEvent *ev) { if (obj == parent()) { if (ev->type() == QEvent::Show) { QHeaderView *hv = qobject_cast<QHeaderView*>(obj); for (int i = 0; i < hv->count(); ++i) hv->setSectionResizeMode(i, QHeaderView::Interactive); } else if (ev->type() == QEvent::Hide) { QHeaderView *hv = qobject_cast<QHeaderView*>(obj); for (int i = 0; i < hv->count(); ++i) hv->setSectionResizeMode(i, i == m_columnToStretch ? QHeaderView::Stretch : QHeaderView::ResizeToContents); } else if (ev->type() == QEvent::Resize) { QHeaderView *hv = qobject_cast<QHeaderView*>(obj); if (hv->sectionResizeMode(m_columnToStretch) == QHeaderView::Interactive) { QResizeEvent *re = static_cast<QResizeEvent*>(ev); int diff = re->size().width() - re->oldSize().width() ; hv->resizeSection(m_columnToStretch, qMax(32, hv->sectionSize(1) + diff)); } } } return false; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void StatsGenODFWidget::setupGui() { // Setup the TableView and Table Models QHeaderView* headerView = new QHeaderView(Qt::Horizontal, m_ODFTableView); headerView->sectionResizeMode(QHeaderView::Interactive); m_ODFTableView->setHorizontalHeader(headerView); headerView->show(); m_OdfBulkTableModel = new SGODFTableModel; m_OdfBulkTableModel->setCrystalStructure(m_CrystalStructure); m_OdfBulkTableModel->setInitialValues(); m_ODFTableView->setModel(m_OdfBulkTableModel); m_ODFTableModel = new SGODFTableModel; m_ODFTableModel->setCrystalStructure(m_CrystalStructure); m_ODFTableModel->setInitialValues(); m_ODFTableView->setModel(m_ODFTableModel); QAbstractItemDelegate* idelegate = m_ODFTableModel->getItemDelegate(); m_ODFTableView->setItemDelegate(idelegate); addODFTextureBtn->setToolTip("Add ODF Weight"); deleteODFTextureBtn->setToolTip("Delete ODF Weight"); m_PlotCurves.push_back(new QwtPlotCurve); m_PlotCurves.push_back(new QwtPlotCurve); m_PlotCurves.push_back(new QwtPlotCurve); }
TEventsLog::TEventsLog(QWidget *obj_MainWindow) : QWidget(obj_MainWindow) { this->obj_MainWindow=obj_MainWindow; QVBoxLayout *EventsList_IntLayout = new QVBoxLayout(); setLayout(EventsList_IntLayout); EventsList_TableView=new xTableView(this); #ifdef __i386__ EventsList_TableView->setMinimumHeight(300); EventsList_TableView->setMinimumWidth(600); #endif EventsList_IntLayout->addWidget(EventsList_TableView); EventsList_TableView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); EventsList_TableView->setStyleSheet(xTableViewStyleSheet); EventsList_TableView->verticalHeader()->setVisible(false); //EventsList_TableView->setShowGrid(false); QHeaderView *verticalHeader = EventsList_TableView->verticalHeader(); #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) verticalHeader->sectionResizeMode(QHeaderView::Fixed); #else verticalHeader->setResizeMode(QHeaderView::Fixed); #endif verticalHeader->setDefaultSectionSize(60); EventsList_TableView->setModel(&EventsList_Model); EventsList_TableView->setItemDelegate(new EventsList_ItemDelegate()); #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) EventsList_TableView->verticalHeader()->setDefaultAlignment(Qt::AlignVCenter|Qt::AlignRight); #endif Retranslate(); OscIndex=0; Load(); }
int main( int argc, char* argv[] ) { QApplication app( argc, argv ); QTableWidget* tv = new QTableWidget(); tv->setRowCount( 1440 ); tv->setColumnCount( 3 ); tv->setShowGrid( false ); QHeaderView* vh = tv->verticalHeader(); vh->sectionResizeMode( QHeaderView::Fixed ); vh->setDefaultSectionSize( 4 ); QLabel* lbl = new QLabel( "abc" ); tv->setCellWidget( 1, 1, lbl ); tv->setSpan( 1, 1, 10, 1 ); tv->show(); app.exec(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void StatsGenPlotWidget::setupGui() { distributionTypeCombo->blockSignals(true); distributionTypeCombo->addItem(DREAM3D::StringConstants::BetaDistribution.toLatin1().data()); distributionTypeCombo->addItem(DREAM3D::StringConstants::LogNormalDistribution.toLatin1().data()); distributionTypeCombo->addItem(DREAM3D::StringConstants::PowerLawDistribution.toLatin1().data()); distributionTypeCombo->blockSignals(false); // Setup the TableView and Table Models QHeaderView* headerView = new QHeaderView(Qt::Horizontal, m_TableView); headerView->sectionResizeMode(QHeaderView::Interactive); m_TableView->setHorizontalHeader(headerView); headerView->show(); // Setup the Qwt Plot Widget //plot->setCanvasBackground(QColor(Qt::white)); //m_PlotView->canvas()->setFrameShape(QFrame::NoFrame); m_grid = new QwtPlotGrid; m_grid->enableXMin(true); m_grid->enableYMin(true); #if (QWT_VERSION > 0x060000) m_grid->setMajorPen(QPen(Qt::gray, 0, Qt::SolidLine)); m_grid->setMinorPen(QPen(Qt::lightGray, 0, Qt::DotLine)); #else m_grid->setMajPen(QPen(Qt::gray, 0, Qt::SolidLine)); m_grid->setMinPen(QPen(Qt::lightGray, 0, Qt::DotLine)); #endif m_grid->attach(m_PlotView); resetTableModel(); if (NULL != m_TableModel) { // Update the plots updatePlotCurves(); } }
MatrixDsp::MatrixDsp(QWidget *parent) : QWidget(parent) { QHeaderView *vHeader; QHeaderView *hHeader; // set up quantization and compression ratio labels whichQM = new QLabel(tr("non-uniform quantization")); whichQM->setAlignment(Qt::AlignCenter); cmpRate = new QLabel(tr("compression ratio: unavailable")); cmpRate->setAlignment(Qt::AlignCenter); qmLabel = new QLabel(tr("Quantization Table")); qmLabel->setAlignment(Qt::AlignCenter); oriLabel = new QLabel(tr("DCT (8x8 block)")); oriLabel->setAlignment(Qt::AlignCenter); qtzLabel = new QLabel(tr("Quantized 8x8 block")); qtzLabel->setAlignment(Qt::AlignCenter); // init a grid layout mainLayout = new QGridLayout(this); mainLayout->setSpacing(6); // init matrices QMMatrix = new QTableWidget(8, 8, this); vHeader = QMMatrix->verticalHeader(); vHeader->sectionResizeMode(QHeaderView::Fixed); vHeader->setDefaultSectionSize(22); vHeader->hide(); hHeader = QMMatrix->horizontalHeader(); hHeader->sectionResizeMode(QHeaderView::Fixed); hHeader->setDefaultSectionSize(40); hHeader->hide(); oriMatrix = new QTableWidget(8, 8, this); vHeader = oriMatrix->verticalHeader(); vHeader->sectionResizeMode(QHeaderView::Fixed); vHeader->setDefaultSectionSize(22); vHeader->hide(); hHeader = oriMatrix->horizontalHeader(); hHeader->sectionResizeMode(QHeaderView::Fixed); hHeader->setDefaultSectionSize(40); hHeader->hide(); qtzMatrix = new QTableWidget(8, 8, this); vHeader = qtzMatrix->verticalHeader(); vHeader->sectionResizeMode(QHeaderView::Fixed); vHeader->setDefaultSectionSize(22); vHeader->hide(); hHeader = qtzMatrix->horizontalHeader(); hHeader->sectionResizeMode(QHeaderView::Fixed); hHeader->setDefaultSectionSize(40); hHeader->hide(); // put quantization and compression ratio labels into the grid layout mainLayout->addWidget(whichQM, 0, 0, 1, 1); mainLayout->addWidget(cmpRate, 1, 0, 1, 1); mainLayout->addWidget(QMMatrix, 2, 0, 7, 1); mainLayout->addWidget(qmLabel, 9, 0, 1, 1); mainLayout->addWidget(oriMatrix, 10, 0, 7, 1); mainLayout->addWidget(oriLabel, 17, 0, 1, 1); mainLayout->addWidget(qtzMatrix, 18, 0, 7, 1); mainLayout->addWidget(qtzLabel, 25, 0, 1, 1); for (int i = 0; i < 8; i++) for (int j = 0; j < 8; j++) { oriMatrix->setItem(i, j, new QTableWidgetItem("")); qtzMatrix->setItem(i, j, new QTableWidgetItem("")); QMMatrix->setItem(i, j, new QTableWidgetItem("")); } }