PDA

View Full Version : pls share the sample code



jagadeesh738
20th May 2015, 07:32
I tried using QvBoxLayout using SetGeometry member function...But output is coming disorder..

plzz Kindly Do NeedFul.


HERE IS THE CODE...


QWidget *wid = new QWidget(this);
wid->setGeometry(0,0,1200,700);

wid->setWindowFlags(Qt::FramelessWindowHint);

wid->setStyleSheet(
"QWidget{"
"background-image: url(:/images/background.jpg);"
"background-position: center bottom;"
"background-repeat: no-repeat;"
"}");


QVBoxLayout *vlayout = new QVBoxLayout(wid);
QGroupBox *groupBox = new QGroupBox("Dates..");

QLabel *lab = new QLabel("Rapport");
lab->setWordWrap(true);
lab->setFixedSize(200,90);
lab->setParent(wid);
lab->setFont(QFont("Trebuchet", 15, QFont::Bold));
lab->setStyleSheet(
"QLabel{"
"color: white;"
"}");

QLabel *modeLab1 = new QLabel("Select Rapport");
modeLab1->setFont(QFont("sans serif",12,QFont::Bold));
modeLab1->setFixedWidth(200);
modeLab1->setStyleSheet(
"QLabel{"
"color: white;"
"}");


radiobutonline1 = new QRadioButton("Rapport Jouralier",this);
radiobutonline1->setGeometry(260,150,180,40);
radiobutonline1->setFont(QFont("sans serif",12,QFont::Bold));
radiobutonline1->setChecked(true);
radiobutonline1->setStyleSheet(
"QRadioButton{"
"color: white;"
"}");
radiobutonline1->setFixedWidth(200);

radiobutoffline1 = new QRadioButton("Rapport Surn Jours",this);
radiobutoffline1->setGeometry(260,180,180,40);
radiobutoffline1->setFont(QFont("sans serif",12,QFont::Bold));
radiobutoffline1->setChecked(false);
radiobutoffline1->setStyleSheet(
QRadioButton{"
"color: white;"
"}");
radiobutoffline1->setFixedWidth(200);

QLabel *labName = new QLabel();
labName->setText("From Date (DDMMYY)");
labName->setFont(QFont("sans serif",12,QFont::Bold));
labName->setStyleSheet(
"QLabel{"
"color: white;"
"}");

labName->setWordWrap(true);
labName->setFixedWidth(200);

QLabel *labPass = new QLabel();
labPass->setText("End Date (DDMMYY)");
labPass->setFont(QFont("sans serif",12,QFont::Bold));
labPass->setStyleSheet(
"QLabel{"
"color: white;"
"}");
labPass->setWordWrap(true);
labPass->setFixedWidth(200);

editstartDate = new QDateEdit(QDate::currentDate(),this);
editstartDate->setFixedWidth(200);
editstartDate->setFont(QFont("sans serif",12,QFont::Bold));
editstartDate->setCalendarPopup(true);
editstartDate->setAlignment(Qt::AlignJustify);
editstartDate->setDisplayFormat("ddMMyy");

editendDate = new QDateEdit(QDate::currentDate(),this);
editendDate->setFixedWidth(200);
editendDate->setFont(QFont("sans serif",12,QFont::Bold));
editendDate->setCalendarPopup(true);
if(radiobutonline1->isChecked()){
editendDate->setEnabled(false);
}
editendDate->setAlignment(Qt::AlignJustify);
editendDate->setDisplayFormat("ddMMyy");

QLabel *labedit = new QLabel();
labName->setText("Select Combo");
labName->setFont(QFont("sans serif",12,QFont::Bold));
labName->setStyleSheet(
"QLabel{"
"color: white;"
labName->setWordWrap(true);
labName->setFixedWidth(150);


editComboBox = new QComboBox(wid);
editComboBox->setGeometry(230,130,180,40);
editComboBox->addItem("-----Sel-----");
editComboBox->addItem("No");


buttonSubDate = new QPushButton(this);
buttonSubDate->setText("Submit");
buttonSubDate->setFont(QFont("sans serif",12,QFont::Bold));
buttonSubDate->setStyleSheet(
"QPushButton {"
"color: white;"
"}");

buttoncanDate = new QPushButton(this);
buttoncanDate->setText("Cancel");
buttoncanDate->setFont(QFont("sans serif",12,QFont::Bold));
buttoncanDate->setStyleSheet(
"QPushButton {"
"color: white;"
"}");
QHBoxLayout *h0 = new QHBoxLayout;
QHBoxLayout *h01 = new QHBoxLayout;
QHBoxLayout *h1 = new QHBoxLayout;
QHBoxLayout *h11 = new QHBoxLayout;
QHBoxLayout *h12 = new QHBoxLayout;
QHBoxLayout *h2 = new QHBoxLayout;
QHBoxLayout *h3 = new QHBoxLayout;

h0->addWidget(modeLab1);
h0->setAlignment(Qt::LeftToRight);

h1->addWidget(labedit);
h1->addWidget(editComboBox);

h1->addWidget(labName);
h1->addWidget(editstartDate);

QLabel *dummylab = new QLabel();
dummylab->setWordWrap(true);
dummylab->setFixedWidth(200);

h11->addWidget(modeLab1);
h11->addWidget(radiobutonline1);
h12->addWidget(dummylab);
h12->addWidget(radiobutoffline1);

h2->addWidget(labPass);
h2->addWidget(editendDate);
h3->addWidget(buttonSubDate,3,Qt::AlignCenter);
h3->addWidget(buttoncanDate,3,Qt::AlignCenter);

vlayout->addLayout(h0);
vlayout->addLayout(h11);
vlayout->addLayout(h12);
vlayout->addLayout(h1);
vlayout->addLayout(h2);
vlayout->addLayout(h3);
wid->setLayout(vlayout);
wid->show();

wysota
20th May 2015, 08:08
If you use layouts, setGeometry() calls have no effect.