Results 1 to 2 of 2

Thread: adding a QCheckBox to a QLayout makes QWidget not display -- no matter how its added

  1. #1
    Join Date
    Apr 2010
    Posts
    25
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default adding a QCheckBox to a QLayout makes QWidget not display -- no matter how its added

    Hello,

    I'm adding a QCheckBox to a QLayout. The QWidget in which the QLayout resides is not being displayed under Windows 7. It is shown in the taskbar and I can maximize it from there thus making it display but it is not displayed as a regular window. No matter what I tried to get the QCheckBox into the QLayout.
    Here's the code:
    Qt Code:
    1. private:
    2. QSize size;
    3. QBoxLayout* boxLayout;
    4. QFormLayout* formLayout;
    5. QLabel* label;
    6. QDoubleSpinBox* doubleSpinBox;
    7. QLabel* label_2;
    8. QDoubleSpinBox* doubleSpinBox_2;
    9. QLabel* label_3;
    10. QDoubleSpinBox* doubleSpinBox_3;
    11. QLabel* label_4;
    12. QDoubleSpinBox* doubleSpinBox_4;
    13. QLabel* label_5;
    14. QCheckBox* checkBox;
    To copy to clipboard, switch view to plain text mode 
    Declared inside X.h
    Qt Code:
    1. X::X() : size(202,157)
    2. {
    3. boxLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
    4. formLayout = new QFormLayout();
    5. label = new QLabel("a");
    6. doubleSpinBox = new QDoubleSpinBox(this);
    7. doubleSpinBox->setDecimals(3);
    8. doubleSpinBox->setMaximum(1);
    9. doubleSpinBox->setSingleStep(0.001);
    10. formLayout->addRow(label, doubleSpinBox);
    11. label_2 = new QLabel("a");
    12. doubleSpinBox_2 = new QDoubleSpinBox();
    13. doubleSpinBox_2->setDecimals(3);
    14. doubleSpinBox_2->setMaximum(1);
    15. doubleSpinBox_2->setSingleStep(0.001);
    16. formLayout->addRow(label_2, doubleSpinBox_2);
    17. label_3 = new QLabel("a");
    18. doubleSpinBox_3 = new QDoubleSpinBox();
    19. doubleSpinBox_3->setDecimals(3);
    20. doubleSpinBox_3->setMaximum(1);
    21. doubleSpinBox_3->setSingleStep(0.001);
    22. formLayout->addRow(label_3, doubleSpinBox_3);
    23. label_4 = new QLabel("a");
    24. doubleSpinBox_4 = new QDoubleSpinBox();
    25. doubleSpinBox_4->setDecimals(3);
    26. doubleSpinBox_4->setMaximum(1);
    27. doubleSpinBox_4->setSingleStep(0.001);
    28. formLayout->addRow(label_4, doubleSpinBox_4);
    29. boxLayout->addLayout(formLayout);
    30. checkBox = new QCheckBox("a");
    31. //boxLayout->addWidget(checkBox); // enabling this line makes the QWidget X not display
    32. }
    To copy to clipboard, switch view to plain text mode 

    I tried adding a label and the QCheckBox to the QFormLayout and didn't have the QBoxLayout but it didn't work. I thought it's perhaps the QFormLayout only accepting "input QWidgets" and QCheckBox isn't defined as an "input QWidget" according to QDesigner, thus I switched to a QBoxLayout containing a QFormLayout and a QCheckBox to no avail.

    Help!

    Lars

  2. #2
    Join Date
    Apr 2010
    Posts
    25
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: adding a QCheckBox to a QLayout makes QWidget not display -- no matter how its ad

    error lies at different part, see http://www.qtcentre.org/threads/2996...dget-invisible

Similar Threads

  1. Replies: 0
    Last Post: 9th March 2010, 09:44
  2. QWidget - Q_OBJECT makes the widget disappear
    By Sir Rogers in forum Qt Programming
    Replies: 6
    Last Post: 26th January 2010, 00:39
  3. Resize QLayout w/ Mouse...or, a QWidget similar to QDockWidget
    By kiss-o-matic in forum Qt Programming
    Replies: 2
    Last Post: 24th December 2009, 11:05
  4. Adding a QWidget to QToolbar
    By qtUser500 in forum Qt Tools
    Replies: 6
    Last Post: 16th October 2009, 19:16
  5. whether Qcanvas objects be added in QLayout
    By Amrita Singh in forum Newbie
    Replies: 1
    Last Post: 25th February 2009, 10:55

Tags for this Thread

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.