C++ (Qt) QFrame *frame = new QFrame(ui->tabWidget); frame->setStyleSheet( "QFrame { background: black }"); frame->setGeometry(ui->tabWidget->geometry().center().x()/2,ui->tabWidget->geometry().center().y()/2,400,100); frame->show();
C++ (Qt)frame->resize( 400, 100 );frame->move( ( ui->tabWidget->width() - frame->width() ) / 2, ( ui->tabWidget->height() - frame->height() ) / 2 );frame->raise();frame->show();
C++ (Qt)#include <QApplication>#include <QStackedLayout>#include <QGridLayout>#include <QPushButton> int main( int argc, char** argv ){ QApplication app( argc, argv ); QWidget mw; QStackedLayout sl( &mw ); sl.setStackingMode( QStackedLayout::StackAll ); QWidget w1, w2; QGridLayout l( &w1 ); for( int i = 0; i < 5; i++ ) for( int j = 0; j < 5; j++ ) l.addWidget( new QPushButton( QString( "%1:%2" ).arg( i ).arg( j ) ), i, j ); sl.addWidget( &w1 ); QGridLayout l2( &w2 ); QPushButton btn( "I'm the top!" ); btn.setFixedSize( 300, 100 ); l2.addWidget( &btn, 1, 1 ); sl.addWidget( &w2 ); sl.setCurrentIndex( 1 ); mw.show(); return app.exec();}