C++ (Qt)void TestList::showEvent(QShowEvent *e){ GLint dims[2] = {0}; glGetIntegerv(GL_MAX_VIEWPORT_DIMS, &dims[0]); qDebug("%d %d", dims[0], dims[1]);}
import QtQuick 2.9import QtQuick.Window 2.3import QtQuick.Controls 2.2//Item {Window { visible: true width: 600 height: 300 ListView { id:lView //width: 600 //height: 4096 anchors.fill: parent model: DeathList orientation: ListView.Vertical delegate: Rectangle { color: modelData.dead ? "darkred" : "white" width: lView.width height: 50 Text { id:nameField anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter text: modelData.name color: modelData.dead ? "white" : "black" width: contentWidth } Text { anchors.left: nameField.right anchors.leftMargin: 20 anchors.verticalCenter: parent.verticalCenter text: modelData.age + qsTr("years old") color: modelData.dead ? "white" : "black" width: contentWidth } CheckBox { text: qsTr("dead") anchors.right: parent.right anchors.top:parent.top anchors.bottom: parent.bottom checked: modelData.dead onCheckedChanged: modelData.dead = checked } } }}
TestList::TestList(QWidget *p, uint _width) : QQuickWidget(p), width(_width){ qsrand(QTime::currentTime().second()); connect(this, SIGNAL(statusChanged(QQuickWidget::Status)), SLOT(changedStatus(QQuickWidget::Status))); setResizeMode(QQuickWidget::SizeRootObjectToView); // size in code //setResizeMode(QQuickWidget::SizeViewToRootObject); // size in QML QSurfaceFormat fmt = format(); fmt.setSwapBehavior(QSurfaceFormat::SingleBuffer);}void TestList::FillList(){ const int num = 660; for( int i = 0; i < num; i++ ) notebook.append( new NoteEntry("person_"+QString::number(i), qrand()%60+20, i%2) ); rootContext()->setContextProperty("DeathList",QVariant::fromValue(notebook)); setSource(QUrl("qrc:/main.qml")); if( ! rootContext()->isValid() ) { qWarning()<<"QML is not valid"; QApplication::quit(); } resize( width, num * 50 );}
QXcbShmImage: shmget() failed (22: ???????????? ????????) for size 120252000 (911x33000)QXcbConnection: XCB error: 11 (BadAlloc), sequence: 591, resource id: 595, major code: 53 (CreatePixmap), minor code: 0