Results 1 to 2 of 2

Thread: Unable to hide QTableWidget in QVBoxLayout

  1. #1
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Unable to hide QTableWidget in QVBoxLayout

    I'm trying to alter with the visibility of a QTableWidget that's added in QVBoxLayout in constructor of a dialog which pops-up on some conditions. By default, I'm adding the QTableWidget to the constructor along with some other widgets.
    Based on a condition, I'm trying to set the visibility of the table.
    But it happens like QTableWidget always visible on the layout and not getting hidden.

    Qt Code:
    1. // I need to hide in "if" case and show in "else if" case on a QDialog with other widgets
    2. if("CVE" == repoType) // This is one condition
    3. {
    4. if(cceReference_table->isVisible())
    5. {
    6. cceReference_table->setVisible(false);
    7. }
    8. for(int i = 0; i < lst.count(); i++)
    9. {
    10. cveReferences.append(new QLabel());
    11. cveReferences.at(i)->setText("<a href=\"" + references.value(lst.at(i)) + "\">" +
    12. lst.at(i) + "</a>");
    13. cveReferences.at(i)->setTextFormat(Qt::RichText);
    14. cveReferences.at(i)->setTextInteractionFlags(Qt::TextBrowserInteraction);
    15. cveReferences.at(i)->setOpenExternalLinks(true);
    16. vLyt->addWidget(cveReferences.at(i));
    17. }
    18. }
    19. else if("CCE" == repoType)
    20. {
    21. if(!cceReference_table->isVisible())
    22. {
    23. cceReference_table->setVisible(true);
    24. }
    25.  
    26. cceReference_table->setRowCount(lst.count());
    27.  
    28. for(int i = 0; i < lst.count(); i++)
    29. {
    30. cceReference_table->setItem(i, 0, new QTableWidgetItem(lst.at(i)));
    31. cceReference_table->setItem(i, 1, new QTableWidgetItem(references.value(lst.at(i))));
    32. }
    33. }
    To copy to clipboard, switch view to plain text mode 

    I need to hide the QTableWidget from the QVBoxLayout. Is there any way to do this for getting desired result? Thank you.
    Last edited by rawfool; 9th June 2013 at 13:21.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Unable to hide QTableWidget in QVBoxLayout

    Remove the if conditions
    Qt Code:
    1. ...
    2. // if(cceReference_table->isVisible())
    3. // {
    4. cceReference_table->setVisible(false);
    5. // }
    6. ...
    7. //if(!cceReference_table->isVisible())
    8. // {
    9. cceReference_table->setVisible(true);
    10. // }
    11. ...
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. The following user says thank you to Santosh Reddy for this useful post:

    rawfool (10th June 2013)

Similar Threads

  1. QTableWidget do not hide headers on resize, what to do?
    By Bong.Da.City in forum Qt Programming
    Replies: 7
    Last Post: 24th June 2012, 16:39
  2. Unable to update QTableWidget which is on Different QWidget from MainWindow
    By sagar.mangalwedhekar in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2010, 07:07
  3. Replies: 1
    Last Post: 23rd October 2009, 00:37
  4. unable to hide combobox or spinbox in toolbar
    By Sandip in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2008, 11:52
  5. Replies: 1
    Last Post: 4th February 2006, 18:49

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.