Results 1 to 4 of 4

Thread: GUI window

  1. #1
    Join Date
    May 2007
    Posts
    131
    Thanks
    17
    Thanked 4 Times in 2 Posts

    Post GUI window

    hi all

    I am creating a GUI window with two Q3Group Boxes. I was able to create the group boxes but unable to display them on the main widget.
    I am sending my code please look into it & suggest me the necessary modifications.

    Qt Code:
    1. #include <QtGui>
    2. #include <Qt3Support/q3groupbox.h>
    3. #include "new.h"
    4.  
    5. client_window::client_window()
    6. {
    7. createButtonsLayout();
    8. newdisplay();
    9. //createButtonsLayout();
    10. /*maingrid = new QGridLayout;
    11.   maingrid->addWidget(display,0,0);
    12.   maingrid->addWidget(start,1,0);
    13.   maingrid->addWidget(stop,2,0);*/
    14. setLayout(maingrid);
    15. setWindowTitle(tr("Client GUI"));
    16. resize(640,480);
    17. }
    18.  
    19. void client_window::createdisplay()
    20. {
    21. QString format = "png";
    22. QString initialPath = QDir::currentPath() + tr("/untitled.") + format;
    23. QString fileName = QFileDialog::getOpenFileName(this, tr("Open"),
    24. initialPath,tr("%1 Files (*.%2);;All Files (*)")
    25. .arg(format.toUpper()).arg(format));
    26. if (!fileName.isEmpty())
    27. {
    28. QPixmap p(fileName);
    29. //display->setMovie(p);
    30. display->resize(640,480);
    31. p=p.scaled ( display->width(),display->height(), Qt::IgnoreAspectRatio,
    32. Qt::SmoothTransformation );
    33. display->setPixmap(p);
    34. }
    35. }
    36.  
    37. void client_window::createButtonsLayout()
    38. {
    39. start = createButton(tr("Start"),this, SLOT(createdisplay()));
    40. stop = createButton(tr("Stop"), this, SLOT(close()));
    41. }
    42.  
    43. QPushButton *client_window::createButton(const QString &text, QWidget *receiver,
    44. const char *member)
    45. {
    46. QPushButton *button = new QPushButton(text);
    47. button->connect(button, SIGNAL(clicked()), receiver, member);
    48. return button;
    49. }
    50.  
    51. void client_window::newdisplay()
    52. {
    53. //maingrid = new QGridLayout();
    54. display = new QLabel;
    55. display->setObjectName(QString::fromUtf8("Image"));
    56. display->resize(640,480);
    57.  
    58. options = new Q3GroupBox;
    59. options->setObjectName(QString::fromUtf8("options"));
    60. options->setGeometry(QRect(6, 380, 264, 93));
    61. QFont font;
    62. font.setPointSize(11);
    63. options->setFont(font);
    64. options->setColumnLayout(0, Qt::Vertical);
    65. maingrid = new QGridLayout();
    66. QBoxLayout *boxlayout = qobject_cast<QBoxLayout *>(options->layout());
    67. if (boxlayout)
    68. boxlayout->addLayout(maingrid);
    69. maingrid->setAlignment(Qt::AlignTop);
    70. maingrid->setObjectName(QString::fromUtf8("maingrid"));
    71. gridLayout1= new QGridLayout();
    72. gridLayout1->setObjectName(QString::fromUtf8("gridLayout1"));
    73. label = new QLabel(options);
    74. label->setObjectName(QString::fromUtf8("label"));
    75. label->setFont(font);
    76. label->setText("&Port Address");
    77.  
    78.  
    79. gridLayout1->addWidget(label, 0, 0, 1, 1);
    80.  
    81. lineEdit = new QLineEdit(options);
    82. lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
    83. lineEdit->setFont(font);
    84.  
    85.  
    86. gridLayout1->addWidget(lineEdit, 0, 1, 1, 2);
    87.  
    88. spacerItem = new QSpacerItem(53, 20, QSizePolicy::Expanding,
    89. QSizePolicy::Minimum);
    90. gridLayout1->addItem(spacerItem, 1, 0, 1, 1);
    91.  
    92. //start = new QPushButton(options);
    93. //start->setObjectName(QString::fromUtf8("Start"));
    94. //start->setFont(font);
    95. //start->setText("Start");
    96. //createButtonsLayout();
    97.  
    98. gridLayout1->addWidget(start, 1, 1, 1, 1);
    99.  
    100. //stop = new QPushButton(options);
    101. //stop->setObjectName(QString::fromUtf8("stop"));
    102. //stop->setFont(font);
    103. //stop->setText("Stop");
    104.  
    105. gridLayout1->addWidget(stop, 1, 2, 1, 1);
    106.  
    107. //maingrid = new QGridLayout();
    108. maingrid->addLayout(gridLayout1, 0, 0, 1, 1);
    109. maingrid->addWidget(display,2,0,1,1);
    110.  
    111. logmessages = new Q3GroupBox;
    112. logmessages->setObjectName(QString::fromUtf8("logmessages"));
    113. logmessages->setGeometry(QRect(278, 380, 346, 92));
    114. logmessages->setFont(font);
    115. logmessages->setColumnLayout(0, Qt::Vertical);
    116. gridLayout2 = new QGridLayout();
    117. QBoxLayout *boxlayout1 = qobject_cast<QBoxLayout *>(logmessages->layout());
    118.  
    119. if (boxlayout1)
    120. boxlayout1->addLayout(gridLayout2);
    121. gridLayout2->setAlignment(Qt::AlignTop);
    122. gridLayout2->setObjectName(QString::fromUtf8("gridLayout2"));
    123. //maingrid->addLayout(gridLayout2,0,1,1,1);
    124. //graphicsView = new QGraphicsView(centralwidget);
    125. //graphicsView->setObjectName(QString::fromUtf8("graphicsView"));
    126. //graphicsView->setGeometry(QRect(5, 9, 620, 369));
    127. //graphicsView->setAutoFillBackground(true);
    128. //MainWindow->setCentralWidget(centralwidget);
    129. label->setBuddy(lineEdit);
    130. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by marcel; 6th May 2008 at 09:49. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: GUI window

    First things I notice are that you don't set a parent for the group box and you don't add it to a layout.

    Try doing that and see if you get anymore problems.

  3. #3
    Join Date
    May 2007
    Posts
    131
    Thanks
    17
    Thanked 4 Times in 2 Posts

    Default Re: GUI window

    How to create parent for QGroupBox

  4. #4
    Join Date
    Oct 2007
    Location
    Cracow
    Posts
    56
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: GUI window

    add QGroupBox to layout and it set parent for this widget

Similar Threads

  1. Set a window as child at runtime
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 26th November 2007, 09:30
  2. Change shape of window / animate window
    By sabeesh in forum Qt Programming
    Replies: 3
    Last Post: 31st October 2007, 08:16
  3. Replies: 1
    Last Post: 11th September 2007, 13:34
  4. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 08:41
  5. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 10:21

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.