ganapathi
17th February 2016, 05:19
Hi,
I used the following concepts to display the incoming images scroll from left to right in the main window. The problem I have is there is a flicker between the images that occurs. How do i remove it? I tried using Qt:WA_PaintOnScreen , Qt:WA_NoSystemBackground attributes. But nothing changed.
QScrollArea *scrollArea;
//widget inside scroll area
QWidget *scrollAreaWidgetContents;
//Horizontal Box Layout
QHBoxLayout *horizontalLayout;
//Image loaded to find the width and height to resize the scroll area.
QImage img(QString::fromUtf8("../../../Downloads/red_star.png"));
scrollArea = new QScrollArea(this->centralWidget());
//Adding the size of the scrollbar with the image width
int intWidth=img.width()*2.5+qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent)*2;
//Adding the size of the scrollbar with the image Height
int intHeight=img.height()+qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent)*2;
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff) ;
//Sizing the scroll area and the inside widget
scrollArea->setGeometry(QRect(0, 0,intWidth ,intHeight));
scrollArea->setWidgetResizable(true);
scrollAreaWidgetContents = new QWidget();
scrollAreaWidgetContents->setGeometry(QRect(0, 0, intWidth, intHeight));
Making the main window width to the scroll area width
this->setFixedWidth(scrollArea->width());
horizontalLayout = new QHBoxLayout(scrollAreaWidgetContents);
scrollArea->setWidget(scrollAreaWidgetContents);
//Image static array
QString strImages[]= {"../../../Downloads/red_star.png","../../../Downloads/green_star.png","../../../Downloads/yellow_star.png"};
//Add the image in the left side of the previous one (Note the color)
for(int iCount=0; iCount<3; iCount++)
{
QLabel *label = new QLabel(QStringLiteral("label"),scrollAreaWidgetContents);
label->setPixmap(QPixmap(strImages[iCount]));
//Adding the new image to the left of previous image
horizontalLayout->insertWidget(0,label);
}
Thanks in advance
I used the following concepts to display the incoming images scroll from left to right in the main window. The problem I have is there is a flicker between the images that occurs. How do i remove it? I tried using Qt:WA_PaintOnScreen , Qt:WA_NoSystemBackground attributes. But nothing changed.
QScrollArea *scrollArea;
//widget inside scroll area
QWidget *scrollAreaWidgetContents;
//Horizontal Box Layout
QHBoxLayout *horizontalLayout;
//Image loaded to find the width and height to resize the scroll area.
QImage img(QString::fromUtf8("../../../Downloads/red_star.png"));
scrollArea = new QScrollArea(this->centralWidget());
//Adding the size of the scrollbar with the image width
int intWidth=img.width()*2.5+qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent)*2;
//Adding the size of the scrollbar with the image Height
int intHeight=img.height()+qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent)*2;
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff) ;
//Sizing the scroll area and the inside widget
scrollArea->setGeometry(QRect(0, 0,intWidth ,intHeight));
scrollArea->setWidgetResizable(true);
scrollAreaWidgetContents = new QWidget();
scrollAreaWidgetContents->setGeometry(QRect(0, 0, intWidth, intHeight));
Making the main window width to the scroll area width
this->setFixedWidth(scrollArea->width());
horizontalLayout = new QHBoxLayout(scrollAreaWidgetContents);
scrollArea->setWidget(scrollAreaWidgetContents);
//Image static array
QString strImages[]= {"../../../Downloads/red_star.png","../../../Downloads/green_star.png","../../../Downloads/yellow_star.png"};
//Add the image in the left side of the previous one (Note the color)
for(int iCount=0; iCount<3; iCount++)
{
QLabel *label = new QLabel(QStringLiteral("label"),scrollAreaWidgetContents);
label->setPixmap(QPixmap(strImages[iCount]));
//Adding the new image to the left of previous image
horizontalLayout->insertWidget(0,label);
}
Thanks in advance