following is my problem statement:
create a horizantal layout in display
add stackedwidget to this Hlayout
the stackedwidget contains imagesWidget and loadWidget
the imagesWidget is further divided into gridlayout which contains some icons
so on the stackedwidget i have a plain widget and a widget withe gridlayout
now , when i click on any icon of the gridlayout it should open loadwidget and on to that
my application should be visible(here i am just playing with colors instead of applications)
for this purpose i again divide grid layout into Horizantal layout and adding the apps widget.
i face two problems here:
1) my gridlayout icons on imagesWidget are coming properly but when i select them i can see
under those icons same icons are present( i dont understand how i got duplicate)
2) when i close my application i am following the steps mentioned in exitapp code:
but my background of the loadWidget is still retianed but with icons from imageWidget
unfortunately i cannot paste the connect calls because the loading is not handled by connect
but some external events from some other module.
below is list of steps i am following.
------------------------------------------
display->setLayout(controlsLayout);
display->setLayout(controlsLayout);
imagesWidget->setLayout(imagesLayout);// setting a grid layout for imagesWidget
imgstack
= new QStackedWidget;
// new stacked widget for imagesWidget and loadwidget imgstack->addWidget(imagesWidget);
imgstack->addWidget(loadWidget);
qDebug("imgstack cnt = %d",imgstack->count());
controlsLayout->addWidget(imgstack); // stacked widget to horizantal layout of of display
const char *colors[]={"background-color: white",
"background-color: black",
"background-color: blue",
"background-color: green",
"background-color: yellow",
"background-color: red",
"background-color: pink",
"background-color: cyan",
"background-color: white"
}; // unique colors are given for each widget to identify
for(int apno = 0;apno < 9;apno ++){
appwidgs[apno]->setStyleSheet(colors[apno]);
appstack->addWidget(appwidgs[apno]);
}
controlsLayout=new QHBoxLayout();
display->setLayout(controlsLayout);
imagesWidget = new QWidget;
loadWidget = new QWidget;
QGridLayout *imagesLayout=new QGridLayout();
controlsLayout=new QHBoxLayout();
display->setLayout(controlsLayout);
imagesWidget = new QWidget;
loadWidget = new QWidget;
imagesWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
imagesWidget->setLayout(imagesLayout);// setting a grid layout for imagesWidget
imgstack = new QStackedWidget; // new stacked widget for imagesWidget and loadwidget
imgstack->addWidget(imagesWidget);
imgstack->addWidget(loadWidget);
qDebug("imgstack cnt = %d",imgstack->count());
controlsLayout->addWidget(imgstack); // stacked widget to horizantal layout of of display
appstack = new QStackedWidget; // new stacked widget for applications
const char *colors[]={"background-color: white",
"background-color: black",
"background-color: blue",
"background-color: green",
"background-color: yellow",
"background-color: red",
"background-color: pink",
"background-color: cyan",
"background-color: white"
}; // unique colors are given for each widget to identify
for(int apno = 0;apno < 9;apno ++){
appwidgs[apno] = new QWidget;
appwidgs[apno]->setStyleSheet(colors[apno]);
appstack->addWidget(appwidgs[apno]);
}
To copy to clipboard, switch view to plain text mode
--------------------------
upon click on any of the image the following will be performed.
imgstack->setCurrentIndex(1);
//loadWidget->setStyleSheet("background-color: blue");
qDebug("currindx=%d\n",imgstack->currentIndex());
loadapp();
imgstack->setCurrentIndex(1);
//loadWidget->setStyleSheet("background-color: blue");
qDebug("currindx=%d\n",imgstack->currentIndex());
loadapp();
To copy to clipboard, switch view to plain text mode
--------------------------
loadapp code:
loadWidget->setLayout(hl);
hl->addWidget(appstack,0,0);
qDebug("curr_apps =%d",appstack->currentIndex());
appstack->setCurrentIndex(currpos);
QHBoxLayout *hl = new QHBoxLayout;
loadWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
loadWidget->setLayout(hl);
hl->addWidget(appstack,0,0);
qDebug("curr_apps =%d",appstack->currentIndex());
appstack->setCurrentIndex(currpos);
To copy to clipboard, switch view to plain text mode
---------------------------------------
exitapp code:
appstack->removeWidget(appwidgs[currpos]);
imgstack->removeWidget(loadWidget);
imgstack->setCurrentWidget(imagesWidget);
appstack->removeWidget(appwidgs[currpos]);
imgstack->removeWidget(loadWidget);
imgstack->setCurrentWidget(imagesWidget);
To copy to clipboard, switch view to plain text mode
Bookmarks