跳转至内容
  • 143k 主题
    719k 帖子
    rudagR
    Hello I'm subclassing QHeaderView based on this example and on @Oak77 's post here. The filters are working fine but I can't resize the headers or even click them for sorting. Method resizeColumnsToContents() also doesn't work. What might be wrong? #include "filterheader.h" #include "copytable.h" #include <QHeaderView> #include <QTableView> #include <QLineEdit> #include <QScrollBar> FilterHeader::FilterHeader(QTableView *parent) : QHeaderView(Qt::Horizontal, parent) { _padding = 4; setStretchLastSection(true); setSectionResizeMode(QHeaderView::Stretch); setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter); setSortIndicatorShown(false); connect(this, &QHeaderView::sectionResized, this, &FilterHeader::adjustPositions); connect(parent->horizontalScrollBar(), &QScrollBar::valueChanged, this, &FilterHeader::adjustPositions); } FilterHeader::FilterHeader(CopyTable *parent) : QHeaderView(Qt::Horizontal, parent) { _padding = 4; setStretchLastSection(true); setSectionResizeMode(QHeaderView::Stretch); setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter); setSortIndicatorShown(false); connect(this, &QHeaderView::sectionResized, this, &FilterHeader::adjustPositions); connect(parent->horizontalScrollBar(), &QScrollBar::valueChanged, this, &FilterHeader::adjustPositions); show(); } void FilterHeader::setFilterBoxes(int count) { while (!_editors.empty()) { QLineEdit* editor = _editors.back(); _editors.pop_back(); editor->deleteLater(); } for (int i = 0; i < count; i++) { QLineEdit* editor = new QLineEdit(parentWidget()); editor->setPlaceholderText("Filter"); connect(editor, &QLineEdit::returnPressed, this, &FilterHeader::emitFilterActivated); _editors.push_back(editor); editor->show(); } adjustPositions(); } void FilterHeader::emitFilterActivated() { emit filterActivated(_editors.indexOf(sender())); } QSize FilterHeader::sizeHint() const { QSize size = QHeaderView::sizeHint(); if (!_editors.empty()) { int height = _editors[0]->sizeHint().height(); size.setHeight(size.height() + height + _padding); } return size; } void FilterHeader::updateGeometries() { if (!_editors.empty()) { int height = _editors[0]->sizeHint().height(); setViewportMargins(0, 0, 0, height + _padding); } else setViewportMargins(0, 0, 0, 0); QHeaderView::updateGeometries(); adjustPositions(); } void FilterHeader::adjustPositions() { for (int i = 0; i < _editors.size(); i++) { QLineEdit* editor = _editors[i]; int height = editor->sizeHint().height(); editor->move(sectionPosition(i) - offset() + qobject_cast<QTableView*>(parent())->verticalHeader()->width(), height + (_padding / 2)); editor->resize(sectionSize(i), height); } } QString FilterHeader::filterText(int index) const { if (index >= 0 && index < _editors.size()) return _editors[index]->text(); return QString(); } void FilterHeader::setFilterText(int index, const QString& text) { if (index >= 0 && index < _editors.size()) _editors[index]->setText(text); } void FilterHeader::clearFilters() { for (auto editor : _editors) editor->clear(); } Code below at the end of the function that loads the tableView FilterHeader* header = new FilterHeader(ui->tableView); ui->tableView->setHorizontalHeader(header); header->setFilterBoxes(model->columnCount()); connect(header, &FilterHeader::filterActivated, this, &Extratos::handleFilterActivated);
  • Jobs, project showcases, announcements - anything that isn't directly development
    4k 23k
    4k 主题
    23k 帖子
    V
    Everyone who is trying to cross-compile Qt for Orange Pi 3B can follow this tutorial: https://github.com/vverenich/CrossCompileQtForOpi
  • Everything related to designing and design tools

    129 391
    129 主题
    391 帖子
    J
    In QT Design Studio, Tab Buttons are mostly for navigation within the UI, but each tab doesn’t automatically hide other content. Usually, a StackView or Loader is needed to switch visible content depending on the active tab.
  • Everything related to the QA Tools

    81 219
    81 主题
    219 帖子
    H
    @IamSumit can you reproduce the issue and share the Support Information logs. Please refer to the following Knowledge Base Article regarding how to obtain the Support Information is https://qatools.knowledgebase.qt.io/misc/collecting-support-info/collecting-support-information-linux-mac-windows/
  • Everything related to learning Qt.

    389 2k
    389 主题
    2k 帖子
    Lehomar2vinciL
    Hi there, I'm also looking for teammates (here lonely) if I can help about creative ideas, I'll be proud to be with you (GMT +1, Paris Timezone) Dont be shy and feel free to DM me :) (Having the same name on Discord)
  • 2k 主题
    13k 帖子
    SGaistS
    I think it's worth asking on the bug report system to see whether they are too specific.
  • 4k 主题
    18k 帖子
    GrecKoG
    Le [=] n'étant pas nécessaire ici vu qu'il n'y a rien à capturer dans la lambda. connect(obj1, &MyObject::mySignal , this, [](int arg1){ qDebug() << arg1; });
  • This is where all the posts related to the Qt web services go. Including severe sillyness.
    1k 10k
    1k 主题
    10k 帖子
    SGaistS
    Hi, I think you can use https://forum.qt.io/category/5/qt-io-webservices category for this type of question (moved there by the way). Are these in your "unread" section ? Are they marked as you following them ?