Hi there,
i created a QMainWindow with a toolbar and a QStackedWidget as central widget. This widget holds the content that should be displayed if one clicks a button in the toolbar. So for now, the main page that is dispayed at startup shows 5 different splash screens (simple images). Lets say it should. I'm using a connection from the actiongroup in the toolbar, to switch splashes when hovering a button in the toolbar.
My first version simply used a QLabel that got equipped with a pixmap. Problem: Its slow and if the user is to fast in moving over the toolar, the splashes come one after the other with some noticable delay.
I wanted to rewrite it using a QStackedLayout, but now the labels don't show up. If i set up a label without adding it to the Layout, it shows up just as it should. My code:Why that? it's set up exactly like the central Widget.Qt Code:
setLayout( stack ); stack->addWidget( area0 ); stack->addWidget( area1 ); stack->addWidget( area2 ); stack->addWidget( area3 ); stack->addWidget( area4 ); stack->setCurrentIndex( 0 ); // QLabel *test = new QLabel(this); // test->setPixmap(QPixmap::fromImage(QImage(":/images/splash0.jpg"))); } void mainPage::loadSplashes() { } qDebug() << "showContent called: " << action->objectName(); if ( action->objectName() == "action_Show_Main" ) { stack->setCurrentIndex( 0 ); } else if ( action->objectName() == "action_Show_Photos" ) { stack->setCurrentIndex( 1 ); } else if ( action->objectName() == "action_Show_Movies" ) { stack->setCurrentIndex( 2 ); } else if ( action->objectName() == "action_Show_Games" ) { stack->setCurrentIndex( 3 ); } else if ( action->objectName() == "action_Show_Tools" ) { stack->setCurrentIndex( 4 ); } else { stack->setCurrentIndex( 0 ); } }To copy to clipboard, switch view to plain text mode
Bookmarks