Results 1 to 9 of 9

Thread: QTableWidget without GUI

  1. #1
    Join Date
    Aug 2009
    Posts
    122
    Thanks
    74
    Qt products
    Qt4
    Platforms
    Windows

    Question QTableWidget without GUI

    Hi,

    I'd like to make a table (2D array) to store floating point numbers without using GUI (I have a console application). QTableWidget is not possible without GUI. What class or function should I use to make this table in console.

    Thanks!

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget without GUI

    What You want to do :
    1. Create a table
    2. Show a table on screen

  3. #3
    Join Date
    Aug 2009
    Posts
    122
    Thanks
    74
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget without GUI

    Hi,

    I'd like to make a table for storing numbers for later calculations (not for screen). My current C code is like this:


    Qt Code:
    1. float **myTable = (float**) malloc((cols+2) * sizeof(float*)); if(myTable == NULL) {exit(1);}
    2. for(i = 0; i < cols+1; i++) {myTable[i] = (float*)malloc((rows+1) * sizeof(float)); if(myTable[i] == NULL) {exit(1);}}
    3. for(i=0; i<cols+1; i++){for(j=0; j<rows+1; j++){myTable[i][j]=0.0;}}
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget without GUI

    But generally it has nothing to do with Qt.

    In C++ You can :
    1. use Yours code
    2. create table using new/delete operators (basics of C++)
    3. use some container from Qt ie. QVector

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableWidget without GUI

    I don't know what you are aiming for but if you intend to do matrix operations on such an array then have a look at QGenericMatrix.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget without GUI

    Of course ...u can create a QTableWidget, displaying in GUi is secondary....
    U can create and use it for storing numbers....

    U can refer following code......its not compiled...
    Qt Code:
    1. table=new QTableWidget(row,coll);
    2.  
    3. int row = filesTable->rowCount();
    4. filesTable->insertRow(row);
    5.  
    6. for(int i=0;i<colcount;i++)
    7. {
    8. QTableWidgetItem *newItem = new QTableWidgetItem(cellItemat(i));
    9. filesTable->setItem(row,i,newItem);
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTableWidget without GUI

    ... and by doing so you make your console only program dependent on the GUI library, add a bunch of unneeded overhead, and generally confuse the next person that has to maintain it a year from now.

  8. #8
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget without GUI

    else wat can be done Cris?

  9. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTableWidget without GUI

    Lesiok and Wysota have provided other options.

Similar Threads

  1. Qtablewidget example
    By thefatladysingsopera in forum Newbie
    Replies: 2
    Last Post: 29th July 2011, 09:27
  2. QTableWidget - D&D
    By GrahamLabdon in forum Newbie
    Replies: 1
    Last Post: 27th May 2011, 08:48
  3. Replies: 1
    Last Post: 6th January 2011, 04:19
  4. QTableWidget
    By deeee in forum Qt Programming
    Replies: 6
    Last Post: 26th May 2010, 18:31
  5. QTableWidget
    By Afflicted.d2 in forum Qt Programming
    Replies: 1
    Last Post: 16th November 2006, 03:42

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.