Results 1 to 10 of 10

Thread: Combobox Delegate 25.000 records

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2007
    Posts
    201
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    22

    Default Re: Combobox Delegate 25.000 records

    Hello everybody,

    I have connected 2 database for the program,

    Qt Code:
    1. db = QSqlDatabase::addDatabase("QPSQL");
    2. db.setHostName("10.0.0.11");
    3. db.setPort(5432);
    4. db.setDatabaseName(comboDonem->currentText());
    5. db.setUserName(lineKullanici->text());
    6. db.setPassword(lineSifre->text());
    To copy to clipboard, switch view to plain text mode 

    and the other one is

    Qt Code:
    1. QSqlDatabase::database("in_mem_db", false).close();
    2. QSqlDatabase::removeDatabase("in_mem_db");
    3. cachedb = QSqlDatabase::addDatabase("QSQLITE", "in_mem_db");
    4. cachedb.setDatabaseName(":memory:");
    5. if (!cachedb.open())
    6. {
    7. QMessageBox::warning(this, tr("Unable to open database"), tr("An error occured while opening the connection: ") + cachedb.lastError().text());
    8. return false;
    9. }
    To copy to clipboard, switch view to plain text mode 

    I could load the cache and select from cache. But the problem I have is when I go to another page(another .h file), I could not connect to cache. I could only connect db. (PQSQL)

    I want to know How could I connect the cache and select from there.

  2. #2
    Join Date
    May 2006
    Posts
    788
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    49
    Thanked 48 Times in 46 Posts

    Default Re: Combobox Delegate 25.000 records

    simple point your cache connecion on query

    QSqlQuery query("",cachedb);

    like sql example

    connect / query to first db is
    QSqlQuery query();
    connect / query to sqlite memory
    QSqlQuery query("",cachedb);

    you can now query to all db listed on
    QStringList QSqlDatabase::connectionNames () [static]

    if you not like to save db pointer:

    QSqlDatabase QSqlDatabase::database ( const QString & connectionName = QLatin1String( defaultConnection ), bool open = true ) [static]

  3. #3
    Join Date
    Jan 2007
    Posts
    201
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    22

    Default Re: Combobox Delegate 25.000 records

    Dear Patric

    Thank you for your reply again, but it didnt solve my problem actually.

    Should I have to connect to cachedb on main.cpp?

    Because what I do is on main cpp starts a entrance .ui which you log on the postgresql. In which i also connect to cachedb. After that you go to the mainpage.h. The problem I have is I could not connect to cache in the mainpage.h

  4. #4
    Join Date
    Jan 2007
    Posts
    201
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    22

    Default Re: Combobox Delegate 25.000 records

    Dear Patric,

    I am trying mybest. But when I close the form that I created cachedb, and open another form, I lost connectiong to the cachedb. But default db connection(PQSQL) stays. Please help me...

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.