Results 1 to 7 of 7

Thread: A variable in setTable()

  1. #1
    Join Date
    Apr 2011
    Posts
    67
    Thanks
    22
    Thanked 5 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default A variable in setTable()

    Hello,is it possible to have a variable in
    Qt Code:
    1. tableModel->setTable("myvariable");
    To copy to clipboard, switch view to plain text mode 
    if the table selected change oftenly?.
    Last edited by thefatladysingsopera; 1st August 2011 at 17:30.

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A variable in setTable()

    IMO the answer is YES.
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Apr 2011
    Posts
    67
    Thanks
    22
    Thanked 5 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: A variable in setTable()

    How is it done?.

  4. #4
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A variable in setTable()

    You can write a slot/function like this

    Qt Code:
    1. void MyClass::tableSelected (const QString & tableName)
    2. {
    3. if (tableName != tableModel->tableName()) {
    4. tableModel->setTable (tableName);
    5. tableModel->select(); // to populate the model
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 
    A camel can go 14 days without drink,
    I can't!!!

  5. #5
    Join Date
    Apr 2011
    Posts
    67
    Thanks
    22
    Thanked 5 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: A variable in setTable()

    This seems to work

    Qt Code:
    1. QString japan = "tables";
    2. tablesModel->setTable(japan);
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A variable in setTable()

    if you don't call select() the model will not be populated
    A camel can go 14 days without drink,
    I can't!!!

  7. #7
    Join Date
    Apr 2011
    Posts
    67
    Thanks
    22
    Thanked 5 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: A variable in setTable()

    The models are working okay and everything is working as it should. The set table part was the only problem.

    Thanks.

Similar Threads

  1. How to use an external variable ?
    By Computer Hater in forum General Programming
    Replies: 10
    Last Post: 25th June 2011, 04:45
  2. variable
    By Atuti2009 in forum Qt Programming
    Replies: 8
    Last Post: 18th November 2009, 09:04
  3. Signal from variable
    By waynew in forum Newbie
    Replies: 2
    Last Post: 18th November 2009, 01:18
  4. QSqlRelationalTableModel settable unable to find
    By nietzsche in forum Qt Programming
    Replies: 0
    Last Post: 25th May 2009, 22:51
  5. Environment variable
    By Pragya in forum Qt Programming
    Replies: 2
    Last Post: 25th May 2007, 13:02

Tags for this Thread

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.