Results 1 to 3 of 3

Thread: access on main window from anothe window (e.g Dialog)

  1. #1
    Join Date
    Jul 2010
    Posts
    30
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default access on main window from anothe window (e.g Dialog)

    Good evening everybody...

    My Question as simple as in the title !!
    I try to write in line edit witch is in the main window,while my button exist on another window (dialog window).

    When I try to make that, I put in the event handler the dialog button:
    Qt Code:
    1. MainWindow::ui->lineEdit_1->text() = :ui->lineEdit_2->text() ;
    To copy to clipboard, switch view to plain text mode 
    while :lineEdit_1 is in the main window and :lineEdit_2 is in the dialoge.

    but the honorable compiler tell me that :
    1) Object missing in reference to 'MainWindow::ui' .............in mainwindow.h
    2)from this location .............in dialog.cpp

    I have search about this, but I didn't understand the meant.Let alone most of what I found was about multi threading not about forms.

    Thank you.

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: access on main window from anothe window (e.g Dialog)

    Use signals and slots to update your lineEdit
    LE: also you will need setText(QString); (or &) because the text() returns the QString, so you cant do assignment to lineedit.text().
    Last edited by Zlatomir; 31st July 2010 at 00:57.

  3. #3
    Join Date
    Jul 2010
    Posts
    30
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: access on main window from anothe window (e.g Dialog)

    Zlatomir .Sorry for the delay.

    Thank you for your replay.
    I think that your suggestion is more professional ,but I have found another simple solution by make function in class dialog.This functoin have to return the content of lineEdit.
    e.g
    Qt Code:
    1. QString dialog::getLineEditText() const
    2. {
    3. return ui->lineEdit->text();
    4. }
    To copy to clipboard, switch view to plain text mode 

    Then call it like after execute the dialog

    Qt Code:
    1. if (x.exec() == QDialog::Accepted)
    2. ui->lineEdit->setText(x.getLineEditText());
    To copy to clipboard, switch view to plain text mode 


    THANK YOU FOR YOUR INTEREST.

Similar Threads

  1. Embed dialog in main window
    By The_Fallen in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2010, 16:06
  2. Replies: 4
    Last Post: 10th February 2010, 07:56
  3. Qt 4.6.0: Opening a dialog from a main window
    By dmginc in forum Qt Programming
    Replies: 3
    Last Post: 14th January 2010, 13:16
  4. access main window from function
    By eric in forum Qt Programming
    Replies: 6
    Last Post: 19th January 2008, 22:29
  5. Crash during sending list from dialog to main window
    By Djony in forum Qt Programming
    Replies: 5
    Last Post: 23rd November 2006, 20:43

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.