Results 1 to 2 of 2

Thread: pls share the sample code

  1. #1
    Join Date
    May 2015
    Posts
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default pls share the sample code

    I tried using QvBoxLayout using SetGeometry member function...But output is coming disorder..

    plzz Kindly Do NeedFul.


    HERE IS THE CODE...

    Qt Code:
    1. QWidget *wid = new QWidget(this);
    2. wid->setGeometry(0,0,1200,700);
    3.  
    4. wid->setWindowFlags(Qt::FramelessWindowHint);
    5.  
    6. wid->setStyleSheet(
    7. "QWidget{"
    8. "background-image: url(:/images/background.jpg);"
    9. "background-position: center bottom;"
    10. "background-repeat: no-repeat;"
    11. "}");
    12.  
    13.  
    14. QVBoxLayout *vlayout = new QVBoxLayout(wid);
    15. QGroupBox *groupBox = new QGroupBox("Dates..");
    16.  
    17. QLabel *lab = new QLabel("Rapport");
    18. lab->setWordWrap(true);
    19. lab->setFixedSize(200,90);
    20. lab->setParent(wid);
    21. lab->setFont(QFont("Trebuchet", 15, QFont::Bold));
    22. lab->setStyleSheet(
    23. "QLabel{"
    24. "color: white;"
    25. "}");
    26.  
    27. QLabel *modeLab1 = new QLabel("Select Rapport");
    28. modeLab1->setFont(QFont("sans serif",12,QFont::Bold));
    29. modeLab1->setFixedWidth(200);
    30. modeLab1->setStyleSheet(
    31. "QLabel{"
    32. "color: white;"
    33. "}");
    34.  
    35.  
    36. radiobutonline1 = new QRadioButton("Rapport Jouralier",this);
    37. radiobutonline1->setGeometry(260,150,180,40);
    38. radiobutonline1->setFont(QFont("sans serif",12,QFont::Bold));
    39. radiobutonline1->setChecked(true);
    40. radiobutonline1->setStyleSheet(
    41. "QRadioButton{"
    42. "color: white;"
    43. "}");
    44. radiobutonline1->setFixedWidth(200);
    45.  
    46. radiobutoffline1 = new QRadioButton("Rapport Surn Jours",this);
    47. radiobutoffline1->setGeometry(260,180,180,40);
    48. radiobutoffline1->setFont(QFont("sans serif",12,QFont::Bold));
    49. radiobutoffline1->setChecked(false);
    50. radiobutoffline1->setStyleSheet(
    51. "color: white;"
    52. "}");
    53. radiobutoffline1->setFixedWidth(200);
    54.  
    55. QLabel *labName = new QLabel();
    56. labName->setText("From Date (DDMMYY)");
    57. labName->setFont(QFont("sans serif",12,QFont::Bold));
    58. labName->setStyleSheet(
    59. "QLabel{"
    60. "color: white;"
    61. "}");
    62.  
    63. labName->setWordWrap(true);
    64. labName->setFixedWidth(200);
    65.  
    66. QLabel *labPass = new QLabel();
    67. labPass->setText("End Date (DDMMYY)");
    68. labPass->setFont(QFont("sans serif",12,QFont::Bold));
    69. labPass->setStyleSheet(
    70. "QLabel{"
    71. "color: white;"
    72. "}");
    73. labPass->setWordWrap(true);
    74. labPass->setFixedWidth(200);
    75.  
    76. editstartDate = new QDateEdit(QDate::currentDate(),this);
    77. editstartDate->setFixedWidth(200);
    78. editstartDate->setFont(QFont("sans serif",12,QFont::Bold));
    79. editstartDate->setCalendarPopup(true);
    80. editstartDate->setAlignment(Qt::AlignJustify);
    81. editstartDate->setDisplayFormat("ddMMyy");
    82.  
    83. editendDate = new QDateEdit(QDate::currentDate(),this);
    84. editendDate->setFixedWidth(200);
    85. editendDate->setFont(QFont("sans serif",12,QFont::Bold));
    86. editendDate->setCalendarPopup(true);
    87. if(radiobutonline1->isChecked()){
    88. editendDate->setEnabled(false);
    89. }
    90. editendDate->setAlignment(Qt::AlignJustify);
    91. editendDate->setDisplayFormat("ddMMyy");
    92.  
    93. QLabel *labedit = new QLabel();
    94. labName->setText("Select Combo");
    95. labName->setFont(QFont("sans serif",12,QFont::Bold));
    96. labName->setStyleSheet(
    97. "QLabel{"
    98. "color: white;"
    99. labName->setWordWrap(true);
    100. labName->setFixedWidth(150);
    101.  
    102.  
    103. editComboBox = new QComboBox(wid);
    104. editComboBox->setGeometry(230,130,180,40);
    105. editComboBox->addItem("-----Sel-----");
    106. editComboBox->addItem("No");
    107.  
    108.  
    109. buttonSubDate = new QPushButton(this);
    110. buttonSubDate->setText("Submit");
    111. buttonSubDate->setFont(QFont("sans serif",12,QFont::Bold));
    112. buttonSubDate->setStyleSheet(
    113. "color: white;"
    114. "}");
    115.  
    116. buttoncanDate = new QPushButton(this);
    117. buttoncanDate->setText("Cancel");
    118. buttoncanDate->setFont(QFont("sans serif",12,QFont::Bold));
    119. buttoncanDate->setStyleSheet(
    120. "color: white;"
    121. "}");
    122. QHBoxLayout *h0 = new QHBoxLayout;
    123. QHBoxLayout *h01 = new QHBoxLayout;
    124. QHBoxLayout *h1 = new QHBoxLayout;
    125. QHBoxLayout *h11 = new QHBoxLayout;
    126. QHBoxLayout *h12 = new QHBoxLayout;
    127. QHBoxLayout *h2 = new QHBoxLayout;
    128. QHBoxLayout *h3 = new QHBoxLayout;
    129.  
    130. h0->addWidget(modeLab1);
    131. h0->setAlignment(Qt::LeftToRight);
    132.  
    133. h1->addWidget(labedit);
    134. h1->addWidget(editComboBox);
    135.  
    136. h1->addWidget(labName);
    137. h1->addWidget(editstartDate);
    138.  
    139. QLabel *dummylab = new QLabel();
    140. dummylab->setWordWrap(true);
    141. dummylab->setFixedWidth(200);
    142.  
    143. h11->addWidget(modeLab1);
    144. h11->addWidget(radiobutonline1);
    145. h12->addWidget(dummylab);
    146. h12->addWidget(radiobutoffline1);
    147.  
    148. h2->addWidget(labPass);
    149. h2->addWidget(editendDate);
    150. h3->addWidget(buttonSubDate,3,Qt::AlignCenter);
    151. h3->addWidget(buttoncanDate,3,Qt::AlignCenter);
    152.  
    153. vlayout->addLayout(h0);
    154. vlayout->addLayout(h11);
    155. vlayout->addLayout(h12);
    156. vlayout->addLayout(h1);
    157. vlayout->addLayout(h2);
    158. vlayout->addLayout(h3);
    159. wid->setLayout(vlayout);
    160. wid->show();
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 20th May 2015 at 08:07. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: pls share the sample code

    If you use layouts, setGeometry() calls have no effect.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Tree sample code
    By nuliknol in forum Qt Programming
    Replies: 3
    Last Post: 24th January 2015, 22:38
  2. QUdpSocket sample code
    By alimooghashang in forum Qt Programming
    Replies: 3
    Last Post: 14th November 2013, 20:59
  3. Export/share code snippets?
    By fonzi337 in forum Qt Tools
    Replies: 3
    Last Post: 24th October 2013, 12:47
  4. Qt video gui sample code
    By sanda199 in forum Newbie
    Replies: 5
    Last Post: 24th January 2013, 14:39
  5. Sample code to use QTreeWidget and QStackWidget
    By Jeff100 in forum Qt Programming
    Replies: 1
    Last Post: 22nd December 2010, 08:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.