Results 1 to 5 of 5

Thread: Getting TableView to strech with Dialog

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Posts
    48
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Getting TableView to strech with Dialog

    I'm creating a simple Dialog which contains a TableView. What I'm having problems with is:
    1) getting the TavleView to expand to the size of the model and there by expand the size of the Dialog and
    2) getting the TableView to strech as the Dialog box is enlarged.

    I used Designer to create the object. I created a Dialog without buttons. Placed a vertical layout in it and place a tableview within the vertical layout. Nothing else.

    I use the following code to display it but I can't get the desired effects. I tried the setSizeConstraint (I found in another example) but it just shrinks the TableView. The resize seems to have no affect.

    Does anyone have a suggestion? Thanks

    Qt Code:
    1. #include <QDialog>
    2. #include <QTableView>
    3.  
    4. #include "ui_View.h"
    5.  
    6. //-----------------------------------------------------------------------------------
    7.  
    8. class CViewInputs : public QDialog, public Ui::CView
    9. {
    10. Q_OBJECT
    11.  
    12. public:
    13. // CViewInputs : class constructor method
    14. CViewInputs(QWidget *parent = 0, CHostIFTools * tools=0);
    15.  
    16. // ~CViewInputs : class destrcutor method
    17. ~CViewInputs();
    18.  
    19. private slots:
    20.  
    21. protected:
    22. };
    23.  
    24.  
    25. //-----------------------------------------------------------------------------------
    26.  
    27. CViewInputs::CViewInputs(QWidget *parent)
    28. : QDialog(parent)
    29. {
    30. // create form
    31. setupUi(this);
    32.  
    33. // setup so that form is removed when closed
    34. setAttribute(Qt::WA_DeleteOnClose);
    35.  
    36. // vboxLayout->setSizeConstraint(QLayout::SetFixedSize);
    37.  
    38. // setup model
    39. model.setColumnCount(6);
    40. model.setRowCount(4);
    41.  
    42. // tableView->resize(500,300);
    43.  
    44. // add data to model
    45. item = new QStandardItem( "Packet Counter");
    46. model.setItem(0,0,item);
    47. item = new QStandardItem( QString::number(200) );
    48. model.setItem(0,1,item);
    49. item = new QStandardItem( "Packets Missed");
    50. model.setItem(0,2,item);
    51. item = new QStandardItem( QString::number(10) );
    52. model.setItem(0,3,item);
    53.  
    54. // assign model to view
    55. tableView->setModel( &model );
    56.  
    57. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by db; 20th November 2007 at 17:14.

Similar Threads

  1. Resizing the dialog boxes
    By anju123 in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2007, 10:41
  2. QGraphicsView: Dialog Position Doubt
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2007, 17:48
  3. Communication between MainWindow and a dialog
    By Backslash in forum Newbie
    Replies: 9
    Last Post: 3rd August 2007, 04:27
  4. [itemview] delegation to a dialog ...
    By lauranger in forum Qt Programming
    Replies: 6
    Last Post: 27th November 2006, 10:08
  5. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 14:52

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
  •  
Qt is a trademark of The Qt Company.