Results 1 to 4 of 4

Thread: QTableWidget -> QDockWidget,

  1. #1
    Join Date
    Jan 2006
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default QTableWidget -> QDockWidget,

    Hello,

    i try to put a QTableWidget in a QDockWidget, but I don’t know what I have to do.

    Can everyone help me?

    My Code:
    Qt Code:
    1. void MainWindow::createDockWindows()
    2. {
    3. // first Docker
    4. QDockWidget *dock = new QDockWidget(tr("Text"), this);
    5. dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
    6. customerList = new QListWidget(dock);
    7. customerList->addItems(QStringList() << "Hier soll was stehen");
    8. dock->setWidget(customerList);
    9. dock->setMaximumWidth( 230 );
    10. addDockWidget(Qt::RightDockWidgetArea, dock);
    11.  
    12. /////////////////////////////////////////////////
    13. /////////////////////////////////////////////////
    14. /////////////////////////////////////////////////
    15. // The Table
    16. QStringList headerLables1;
    17. headerLables1 << "Name"
    18. << "Key";
    19.  
    20. tableWidget1 = new QTableWidget();
    21. tableWidget1->setRowCount( 10 );
    22. tableWidget1->setColumnCount( headerLables1.count() );
    23. tableWidget1->setHorizontalHeaderLabels( headerLables1 );
    24.  
    25. QTableWidgetItem *nameCell = new QTableWidgetItem( "name" );
    26. QTableWidgetItem *keyCell = new QTableWidgetItem( "key" );
    27.  
    28. tableWidget1->setItem(0,0,nameCell);
    29. tableWidget1->setItem(1,1,keyCell);
    30.  
    31. tableWidget1->setItem(2,0,nameCell);
    32. tableWidget1->setItem(3,1,keyCell);
    33.  
    34.  
    35. /////////////////////////////////////////////////
    36. /////////////////////////////////////////////////
    37. /////////////////////////////////////////////////
    38.  
    39.  
    40. // second Docker
    41. dock = new QDockWidget(tr("Tabelle"), this);
    42. // insert the table here :confused:
    43.  
    44. ?
    45. .
    46. .
    47. .
    48. ?
    To copy to clipboard, switch view to plain text mode 

    thx

  2. #2
    Join Date
    Jan 2006
    Location
    Skopje, Macedonia
    Posts
    11
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: QTableWidget -> QDockWidget,

    I think you have to set the dock widget as parent of the table.

    whick means:

    create the table

    tableWidget1 = new QTableWidget(dock);

    check the example at trolls

    http://doc.trolltech.com/4.1/mainwin...ckwidgets.html

    GREETZ, chombium

  3. #3
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: QTableWidget -> QDockWidget,

    It's nice to be important but it's more important to be nice.

  4. #4
    Join Date
    Jan 2006
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QTableWidget -> QDockWidget,

    Hello,

    I try setWidget(), and it’s work. But there is one another Problem.
    If i put:
    Qt Code:
    1. tableWidget1->setItem(0,0,nameCell);
    2. tableWidget1->setItem(1,1,keyCell);
    To copy to clipboard, switch view to plain text mode 
    it works, but if I fill two rows:
    Qt Code:
    1. tableWidget1->setItem(0,0,nameCell);
    2. tableWidget1->setItem(1,1,keyCell);
    3.  
    4. tableWidget1->setItem(2,0,nameCell);
    5. tableWidget1->setItem(3,1,keyCell);
    To copy to clipboard, switch view to plain text mode 
    the prog fuckt up if I close that.

    Qt Code:
    1. QStringList headerLables1;
    2. headerLables1 << "Name"<< "Key";
    3.  
    4. tableWidget1 = new QTableWidget();
    5. tableWidget1->setRowCount( 10 );
    6. tableWidget1->setColumnCount( headerLables1.count() );
    7. tableWidget1->setHorizontalHeaderLabels( headerLables1 );
    8.  
    9. QTableWidgetItem *nameCell = new QTableWidgetItem( "name" );
    10. QTableWidgetItem *keyCell = new QTableWidgetItem( "key" );
    11.  
    12. tableWidget1->setItem(0,0,nameCell);
    13. tableWidget1->setItem(1,1,keyCell);
    14.  
    15. //tableWidget1->setItem(2,0,nameCell);
    16. //tableWidget1->setItem(3,1,keyCell);
    17.  
    18.  
    19.  
    20. dock = new QDockWidget(tr("Koordinaten"), this);
    21. dock->setMaximumWidth( 350 );
    22. dock->setWidget( tableWidget1 );
    23. addDockWidget(Qt::RightDockWidgetArea, dock);
    To copy to clipboard, switch view to plain text mode 

    //////////////////////////////
    There is a Problem in QTableWidget.cpp. But i don't know what it’s mean.
    Qt Code:
    1. void QTableModel::clear()
    2. {
    3. for (int i = 0; i < table.count(); ++i) {
    4. if (table.at(i)) {
    5. table.at(i)->model = 0;
    6. delete table.at(i); <---- that’s the problem
    7. table[i] = 0;
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QDockWidget magically disapear
    By 1111 in forum Qt Programming
    Replies: 1
    Last Post: 29th January 2009, 12:44
  2. QComboBox in QTableWidget : display troubles.
    By Nyphel in forum Qt Programming
    Replies: 2
    Last Post: 14th October 2007, 00:29
  3. Replies: 8
    Last Post: 4th February 2007, 01:42
  4. QTableWidget editing question
    By Trasmeister in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 19:46
  5. Replies: 6
    Last Post: 5th March 2006, 22: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.