Results 1 to 5 of 5

Thread: show more lines

  1. #1
    Join Date
    Dec 2010
    Location
    Lithuania
    Posts
    29
    Qt products
    Qt4
    Platforms
    Windows

    Default show more lines

    Hi, I am checking this code but I don't understang how to show more lines.

    Qt Code:
    1. #include "MainWidget.h"
    2.  
    3. MainWidget::MainWidget(QWidget *parent) :
    4. QWidget(parent)
    5. {
    6. CurrentQueryModel = 0;
    7. //CurrentRecord = 0;
    8. DataSourceConnected = false;
    9. tbvStudentList = new QTableView(this);
    10. dlgUpdate = new StudentUpdateDialog(this);
    11. btnUpdate = new QPushButton("Update", this);
    12. mainLayout = new QGridLayout(this);
    13.  
    14. connect(btnUpdate, SIGNAL(clicked()), this, SLOT(clickedButtonUpdate()));
    15. connect(this, SIGNAL(clickedUpdate()), dlgUpdate, SLOT(show()));
    16. connect(this, SIGNAL(changedRecord(QSqlRecord)),
    17. dlgUpdate, SLOT(changeRecord(QSqlRecord)));
    18. connect(dlgUpdate, SIGNAL(executeQuery(QString)),
    19. this, SIGNAL(executeUpdate(QString)));
    20.  
    21. mainLayout->addWidget(tbvStudentList,0, 0, 1, 1);
    22. mainLayout->addWidget(btnUpdate,1, 0, 1, 1);
    23.  
    24. this->setLayout(mainLayout);
    25. }
    26.  
    27. void MainWidget::clickedButtonUpdate(void)
    28. {
    29. emit changedRecord(CurrentRecord);
    30.  
    31. emit clickedUpdate();
    32. //dlgUpdate->show();
    33. }
    34.  
    35. void MainWidget::connectData(void)
    36. {
    37. //QString tmpQuery = "SELECT ID, Firstname, Surname, BirthDay FROM Student";
    38.  
    39. DataSourceConnected = true;
    40. //emit executeQuery(tmpQuery);
    41. changeData();
    42. qDebug() << "Emitted signal executeQuery";
    43. }
    44.  
    45. void MainWidget::processQuery(QSqlQueryModel *parModel)
    46. {
    47. CurrentQueryModel = parModel;
    48. if(CurrentQueryModel == 0) {
    49. qDebug() << "CurrentQueryModel == 0";
    50. } else {
    51. qDebug() << "CurrentQueryModel != 0";
    52. tbvStudentList->setModel(CurrentQueryModel);
    53. CurrentRecord = CurrentQueryModel->record(0);
    54. emit changedRecord(CurrentRecord);
    55. }
    56. }
    57.  
    58. void MainWidget::changeData(void)
    59. {
    60. QString tmpQuery = "SELECT ID, Firstname, Surname, Birthday FROM Student";
    61.  
    62. emit executeQuery(tmpQuery);
    63. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: show more lines

    What lines?
    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.


  3. #3
    Join Date
    Dec 2010
    Location
    Lithuania
    Posts
    29
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: show more lines

    I am making database GUI I have to show student's group name. but in student table I use only group_id. I hope you understand
    I don't know how to show it.

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

    Default Re: show more lines

    No, I don't understand. I think the code you have shown is completely irrelevant to your problem. Whatever the problem is...
    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.


  5. #5
    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: show more lines

    I don't understand either.

    Quote Originally Posted by Shien View Post
    I am making database GUI I have to show student's group name. but in student table I use only group_id.
    You are not selecting anything called group_id from the table called Student.

    Assuming that you have a Student.group_id column, and you have another table that contains group_id/group_name pairs, and you want to display the group_name then you need to join the two tables either directly in SQL or indirectly in code. If you are intending to edit this view then look at QSqlRelationalTableModel.

Similar Threads

  1. Replies: 3
    Last Post: 12th July 2010, 13:12
  2. ComboBox with lines
    By Braunstein in forum Qt Programming
    Replies: 1
    Last Post: 16th March 2010, 08:12
  3. connecting lines?
    By konvex in forum Qt Programming
    Replies: 8
    Last Post: 16th December 2008, 09:00
  4. I want to get lines of text
    By newplayer in forum Qt Programming
    Replies: 11
    Last Post: 29th July 2008, 09:03
  5. how to show vertical lines between colums
    By thomasjoy in forum Qt Programming
    Replies: 4
    Last Post: 22nd August 2007, 15:03

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.