Hi below is my application
LoadApplication loads a set of pushbuttons in Gridlayout
nss1.jpeg is the window once LoadApplication is completed.
#include "mainwindow.h"
#include <QtGui>
void MainWindow::LoadApplication()
{
int a[] = {0,0,0,1,1,1,2,2,2};
int b[] = {3,6,9,3,6,9,3,6,9};
if(button[0]){
delete button[0],button[0]=NULL;
delete previewGroupBox,previewGroupBox=NULL;
delete previewLayout,previewLayout=NULL;
delete calendar,calendar=NULL;
if (Gh)
delete Gh,Gh=NULL;
}
if(!Gh){
display -> setLayout(Gh);
}
for(int i = 0; i < 9; i++)
{
button[i] -> setIconSize(button[i]->rect().size());
Gh -> addWidget(button[i],a[i],b[i],1,3);
button[i] -> setGeometry(a[i],b[i],100,100);
button[i] -> setMaximumSize(100,100);
connect(button[i],SIGNAL(clicked()),this,SLOT(fun()));
}
}
#include "mainwindow.h"
#include <QtGui>
class QCalendarWidget;
void MainWindow::LoadApplication()
{
int a[] = {0,0,0,1,1,1,2,2,2};
int b[] = {3,6,9,3,6,9,3,6,9};
if(button[0]){
delete button[0],button[0]=NULL;
delete previewGroupBox,previewGroupBox=NULL;
delete previewLayout,previewLayout=NULL;
delete calendar,calendar=NULL;
if (Gh)
delete Gh,Gh=NULL;
}
if(!Gh){
Gh = new QGridLayout();
display -> setLayout(Gh);
}
for(int i = 0; i < 9; i++)
{
button[i] = new QPushButton(QIcon("qt4.png"),NULL,this);
button[i] -> setIconSize(button[i]->rect().size());
Gh -> addWidget(button[i],a[i],b[i],1,3);
button[i] -> setGeometry(a[i],b[i],100,100);
button[i] -> setMaximumSize(100,100);
connect(button[i],SIGNAL(clicked()),this,SLOT(fun()));
}
}
To copy to clipboard, switch view to plain text mode
the fun is used to delete the layouts and buttons so that the calendar can be launched.
so nss2.jpeg is window after this fun is called.
but here i observe some strange thing .
even after deleting buttons i can see some buttons in the background.
in the attached jpeg this can be seen clearly..
i need help in understanding , from where those buttons are coming.
//void MainWindow ::fun(int i)
void MainWindow ::fun()
{
for(int i=0;i<9;i++)
if(button[i])
delete button[i],button[i]=NULL;
if (Gh)
delete Gh,Gh=NULL;
display->setLayout(Gh);
createPreviewGroupBox();
Gh->addWidget(previewGroupBox, 0, 0);
Gh -> addWidget(button[0],3,2,1,3);
button[0] -> setGeometry(3,2,100,100);
button[0] -> setMaximumSize(50,50);
connect(button[0],SIGNAL(clicked()),this,SLOT(LoadApplication()));
}
//void MainWindow ::fun(int i)
void MainWindow ::fun()
{
for(int i=0;i<9;i++)
if(button[i])
delete button[i],button[i]=NULL;
if (Gh)
delete Gh,Gh=NULL;
Gh = new QGridLayout;
display->setLayout(Gh);
createPreviewGroupBox();
Gh->addWidget(previewGroupBox, 0, 0);
button[0] = new QPushButton(QIcon("qt4.png"),NULL,this);
Gh -> addWidget(button[0],3,2,1,3);
button[0] -> setGeometry(3,2,100,100);
button[0] -> setMaximumSize(50,50);
connect(button[0],SIGNAL(clicked()),this,SLOT(LoadApplication()));
}
To copy to clipboard, switch view to plain text mode
this is for standard calendar widget
void MainWindow::createPreviewGroupBox()
{
previewGroupBox
= new QGroupBox(tr
("Preview"));
calendar
->setMinimumDate
(QDate(1900,
1,
1));
calendar
->setMaximumDate
(QDate(3000,
1,
1));
calendar->setGridVisible(true);
connect(calendar, SIGNAL(currentPageChanged(int,int)),
this, SLOT(reformatCalendarPage()));
previewLayout->addWidget(calendar, 0, 0, 0);//Qt::AlignCenter);
previewGroupBox->setLayout(previewLayout);
}
void MainWindow::createPreviewGroupBox()
{
previewGroupBox = new QGroupBox(tr("Preview"));
calendar = new QCalendarWidget;
calendar->setMinimumDate(QDate(1900, 1, 1));
calendar->setMaximumDate(QDate(3000, 1, 1));
calendar->setGridVisible(true);
connect(calendar, SIGNAL(currentPageChanged(int,int)),
this, SLOT(reformatCalendarPage()));
previewLayout = new QGridLayout;
previewLayout->addWidget(calendar, 0, 0, 0);//Qt::AlignCenter);
previewGroupBox->setLayout(previewLayout);
}
To copy to clipboard, switch view to plain text mode
Bookmarks