Note that there are some explanatory texts on larger screens.

plurals
  1. POQTableWidget with stylesheet don’t scroll items
    primarykey
    data
    text
    <p>In the following code there are two stylesheets: problemStylesheet and okStylesheet. Everything works fine when I’m using <strong>okStylesheet</strong> for QTableWidget. Labels are scrolling. Problem is that labels are not scrolling if I use <strong>problemStylesheet</strong>. What can cause this problem? I've tried to find the solution, but couldn't find any information that might be helpful.</p> <p>Qt 4.8.0, Mac OS X Lion.</p> <p>Example code:</p> <pre><code>#include &lt;QtGui&gt; int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget *baseWidget = new QWidget; QTableWidget *tableWidget = new QTableWidget(baseWidget); tableWidget-&gt;setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); tableWidget-&gt;setColumnCount(1); tableWidget-&gt;horizontalHeader()-&gt;setVisible(false); tableWidget-&gt;verticalHeader()-&gt;setVisible(false); tableWidget-&gt;horizontalHeader()-&gt;setStretchLastSection(true); tableWidget-&gt;verticalHeader()-&gt;setDefaultSectionSize(52); tableWidget-&gt;setShowGrid(false); tableWidget-&gt;setSelectionMode(QAbstractItemView::SingleSelection); tableWidget-&gt;setSelectionBehavior(QAbstractItemView::SelectRows); QString problemStylesheet = "QTableWidget { background-color: green; } QTableWidget::item { border: 1px solid #000; }"; QString okStylesheet = "QTableWidget { } QTableWidget::item { border: 1px solid #000; }"; tableWidget-&gt;setStyleSheet(problemStylesheet); tableWidget-&gt;setRowCount(20); for (int i = 0; i &lt; 20; ++i) { QLabel *label = new QLabel(QString("").setNum(i), tableWidget); label-&gt;setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); tableWidget-&gt;setCellWidget(i, 0, label); } QVBoxLayout *verticalLayout = new QVBoxLayout(); verticalLayout-&gt;setMargin(0); verticalLayout-&gt;setSpacing(0); verticalLayout-&gt;setContentsMargins(0, 0, 0, 0); baseWidget-&gt;setLayout(verticalLayout); verticalLayout-&gt;addWidget(tableWidget); baseWidget-&gt;show(); return app.exec(); } </code></pre> <p><strong>UPDATE:</strong> It seems like everything is ok on Linux and Windows. So the problem appears only on Mac OS.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload