Results 1 to 4 of 4

Thread: help me for this code? (Sql server in Qt)

  1. #1
    Join Date
    Jan 2013
    Posts
    19
    Thanks
    11

    Question help me for this code? (Sql server in Qt)

    hi Entourage
    help me for this code?
    I do not understand the red part
    #include <QtGui>
    #include <QtSql>

    #include "../connection.h"

    void initializeModel(QSqlTableModel *model)
    {
    model->setTable("person");
    model->setEditStrategy(QSqlTableModel::OnManualSubmit) ;
    model->select();

    model->setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
    model->setHeaderData(1, Qt::Horizontal, QObject::tr("First name"));
    model->setHeaderData(2, Qt::Horizontal, QObject::tr("Last name"));
    }

    QTableView *createView(QSqlTableModel *model, const QString &title = "")
    {
    QTableView *view = new QTableView;
    view->setModel(model);
    #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
    Q_UNUSED(title)
    #else
    view->setWindowTitle(title);
    #endif
    return view;
    }


    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    if (!createConnection())
    return 1;

    QSqlTableModel model;

    initializeModel(&model);

    #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
    QTabWidget *tabWidget = new QTabWidget;
    tabWidget->addTab(createView(&model), "View 1");
    tabWidget->addTab(createView(&model), "View 2");

    tabWidget->showMaximized();
    #else
    QTableView *view1 = createView(&model, QObject::tr("Table Model (View 1)"));
    QTableView *view2 = createView(&model, QObject::tr("Table Model (View 2)"));

    view1->show();
    view2->move(view1->x() + view1->width() + 20, view1->y());
    view2->show();
    #endif


    return app.exec();
    }

    thank you very much

  2. #2
    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: help me for this code? (Sql server in Qt)

    Which red part? There are a couple of red parts here.
    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. The following user says thank you to wysota for this useful post:

    complexcoding (29th January 2013)

  4. #3
    Join Date
    Jan 2013
    Posts
    19
    Thanks
    11

    Default Re: help me for this code? (Sql server in Qt)

    I'm working with a database in Qt
    To display a simple table in the form
    Unfortunately, I do not know nothing
    Please ... Please help!

  5. #4
    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: help me for this code? (Sql server in Qt)

    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. The following user says thank you to wysota for this useful post:

    complexcoding (29th January 2013)

Similar Threads

  1. Replies: 7
    Last Post: 6th September 2012, 07:07
  2. Implementing a TCP Server
    By keelerjr12 in forum Qt Programming
    Replies: 1
    Last Post: 22nd August 2012, 16:26
  3. [TCP Server] Server only sending when terminating
    By papperlapapp in forum Qt Programming
    Replies: 0
    Last Post: 6th December 2010, 19:41
  4. Replies: 5
    Last Post: 2nd June 2009, 19:47
  5. Pasting code from code tag in emacs
    By Gopala Krishna in forum General Discussion
    Replies: 0
    Last Post: 16th February 2007, 05:47

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.