Results 1 to 3 of 3

Thread: Passing DB Query data to another Window and show the values in respective fields

  1. #1
    Join Date
    Feb 2013
    Posts
    7
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Passing DB Query data to another Window and show the values in respective fields

    Hi, I was able send Selecteditem of QListView to a QLineEdit in next window, now I need to send that Selecteditem’s Query information to Second Window’s Form fields. Do I need to use QStringList to hold all the information? Or any other way? guide me thanks

    Here is the source of firstwindow.cpp:

    Qt Code:
    1. void MainWindow::showValue(){
    2.  
    3.  
    4.  
    5. GetValue *v = new GetValue(ui->listView->currentIndex().data().toString());
    6.  
    7. this->hide();
    8.  
    9. v->show();
    10.  
    11. v->setWindowTitle("Form Information");
    12.  
    13. }
    To copy to clipboard, switch view to plain text mode 

    The Second WIndow’s code:

    Qt Code:
    1. GetValue::GetValue(const QString &text,QWidget *parent) :
    2.  
    3. QMainWindow(parent),
    4.  
    5. ui(new Ui::GetValue)
    6.  
    7. {
    8.  
    9. ui->setupUi(this);
    10.  
    11. ui->lineEdit->setText(text);
    12.  
    13. }
    To copy to clipboard, switch view to plain text mode 

    Here I need to show information from first window in the form of a query like:

    Qt Code:
    1. Select * from User where UserName="Selecteditem";
    To copy to clipboard, switch view to plain text mode 

    All the information relating to that row will be displayed in the Second Window’s fields.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Passing DB Query data to another Window and show the values in respective fields

    If you want to pass the qurey, then just pass it as a QString (assuming you wanted to execute the query in second window)

    You could build the query on the second window itself, then it wont be required ot pass anything else other than selected item
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. The following user says thank you to Santosh Reddy for this useful post:

    abhiabhi (21st February 2013)

  4. #3
    Join Date
    Feb 2013
    Posts
    7
    Thanks
    5
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Passing DB Query data to another Window and show the values in respective fields

    Yeah Santosh sir, thats right, how to save the string which is in QLineEdit ? this function ui->lineEdit->setText(text); will display the text from Window one, but I am not able convert it to QString, I tried like QString my_string; my_string = textValue->text();, but the app ended up showing the following error: The program has unexpectedly finished.


    Added after 1 11 minutes:


    I got the string using QString my_string = ui->lineEdit->text();
    Last edited by abhiabhi; 21st February 2013 at 07:05.

Similar Threads

  1. passing values in qml
    By vinayaka in forum Newbie
    Replies: 0
    Last Post: 20th July 2011, 14:36
  2. Passing QTableWidget values to another QWizard page
    By slava in forum Qt Programming
    Replies: 2
    Last Post: 1st July 2010, 14:42
  3. Passing values to custom 'slot' functions (pyqt)
    By Richie in forum Qt Programming
    Replies: 2
    Last Post: 7th September 2009, 08:05
  4. Replies: 7
    Last Post: 25th April 2009, 06:13
  5. Passing Command Line Values?
    By Kapil in forum Newbie
    Replies: 1
    Last Post: 29th March 2006, 09:26

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.