Results 1 to 6 of 6

Thread: QlineEdit - restoring text from hide/closed window.

  1. #1
    Join Date
    Jul 2010
    Posts
    8
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default QlineEdit - restoring text from hide/closed window.

    Hi.

    I've searched a lot but I can't find answer how to do it... I've done by Qt Designer signal/slot which call window hide () function after click on OK button... but after opening this window again by code:

    App *app = new App(this);
    app->show();


    QlineEdit object text is empty - don't save written by me text, is restored to default state (Qline object projected in QtDesigner as empty at start). What to do to always display text which I've writtem in this Qline object ?


    1.
    Qt Code:
    1. void App::on_OK_clicked()
    2. {
    3. (ui->message)->setText(oldMessage);
    4. }
    To copy to clipboard, switch view to plain text mode 

    don't work.

    2. slot/signal which make update () function on QLine when OK button pressed in Qt designer also ...
    Last edited by Wojtek1990; 24th July 2010 at 01:00.

  2. #2
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: QlineEdit - restoring text from hide/closed window.

    Can you post more complete code?

  3. #3
    Join Date
    Jul 2010
    Posts
    8
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QlineEdit - restoring text from hide/closed window.

    Problem seems to be in this code:
    Qt Code:
    1. Tasker *tasker = new Tasker(this);
    2. tasker->show();
    To copy to clipboard, switch view to plain text mode 

    It open new window with default object values. How to open ALREADY HIDDEN window ?

    When I use function Tasker::show(); in file tasker.cpp it works - window is restored to state before hidding.
    But when I use this function in mainwindow.cpp file

    Qt Code:
    1. void MainWindow::on_actionTasker_activated()
    2. {
    3. if (OpenFirstTime == 0) {
    4. Tasker *tasker = new Tasker(this);
    5. tasker->show();
    6. OpenFirstTime=1;
    7. }
    8. else {
    9. //Tasker d;
    10. //d.show(); -> open window just for second
    11. Tasker::show(); // makes error
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

    I got error:

    Qt Code:
    1. Cannot call member function 'Void QWidget::show()' without object
    To copy to clipboard, switch view to plain text mode 

    How to solve it ?
    Last edited by Wojtek1990; 24th July 2010 at 19:49.

  4. #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: QlineEdit - restoring text from hide/closed window.

    Quote Originally Posted by Wojtek1990 View Post
    but after opening this window again by code:

    App *app = new App(this);
    app->show();


    QlineEdit object text is empty
    It's not the same window. It's a similar window.

    If you want to retrieve the data from the closed window, you have to access variables corresponding to this particular window instead of creating a new one.
    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.


  5. The following user says thank you to wysota for this useful post:

    Wojtek1990 (25th July 2010)

  6. #5
    Join Date
    Jul 2010
    Posts
    8
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QlineEdit - restoring text from hide/closed window.

    Quote Originally Posted by wysota View Post
    you have to access variables corresponding to this particular window instead of creating a new one.
    By pointers ? How to do it ? Could anyone post example ?

  7. #6
    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: QlineEdit - restoring text from hide/closed window.

    Hmm... what are your C++ skills? Can you tell a difference between a class and an object?
    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.


Similar Threads

  1. closing dialog window
    By sksingh73 in forum Newbie
    Replies: 1
    Last Post: 21st June 2010, 22:27
  2. Window not closing or destroying
    By spraff in forum Qt Programming
    Replies: 5
    Last Post: 13th December 2008, 15:10
  3. closing of window on pressing ESC key
    By raghvendramisra in forum Newbie
    Replies: 2
    Last Post: 7th January 2008, 02:36
  4. closeEditor() not always closing QLineEdit
    By mclark in forum Qt Programming
    Replies: 8
    Last Post: 27th November 2007, 01:44
  5. Event - closing/activate window
    By chaimar in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2006, 09:12

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.