Results 1 to 14 of 14

Thread: QLineEdit can't update inside QStackedWidget

  1. #1
    Join Date
    Jul 2013
    Posts
    72
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default QLineEdit can't update inside QStackedWidget

    While a QStackedWidget adds several widgets , QLineEdit inside the QStackedWidget can't update .
    Is that a QStackedWidget bug or I miss something ?
    please help.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit can't update inside QStackedWidget

    What do you mean with "can't update"?

    If you set a text it doesn't change?
    You can't type into it?

    Cheers,
    _

  3. #3
    Join Date
    Jul 2013
    Posts
    72
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QLineEdit can't update inside QStackedWidget

    I can type into it ,but it fail when I use setText().

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit can't update inside QStackedWidget

    Very strange.

    Just to be sure: you are calling setText() on the correct line edit, right? I.e. there is no other line edit than the one being displayed.

    Can you create a minimal example that shows the problem?

    Cheers,
    _

  5. #5
    Join Date
    Jul 2013
    Posts
    72
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QLineEdit can't update inside QStackedWidget

    It works well in a minimal example , but it doesn't within my code .
    In my code , it is ok when the stackedwidget adds no more than 5 widgets.. When up to 6, 7,,it fails sometimes.
    It definitely goes wrong with more than 8 widgets(Eache of these widgets contains about 20 qwidgets,llike button,qlineedit ,qdoublespinbox etc.).

  6. #6
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit can't update inside QStackedWidget

    How You recognize which QLineEdit should be updated ? Show some code.

  7. #7
    Join Date
    Jul 2013
    Posts
    72
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QLineEdit can't update inside QStackedWidget

    Thansands of lines ,,,minimal example can't make it goes wrong.

  8. #8
    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 can't update inside QStackedWidget

    Show us code where you initialize widgets in the stacked view and how you later try to call setText() on the proper line edit.
    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.


  9. #9
    Join Date
    Jul 2013
    Posts
    72
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QLineEdit can't update inside QStackedWidget

    if I have initialized widgets in a wrong way , how can it work just fine when adding 3 or 4 widgets?


    Added after 16 minutes:


    This a slice of my code

    Qt Code:
    1. QStackedWidget *TraceConfigDialog::buildStackedWidget()
    2. {
    3. QStackedWidget *stackedWidget = new QStackedWidget();
    4. stackedWidget->addWidget(linearGroupBox());
    5.  
    6. stackedWidget->addWidget(fillingGroupBox());
    7. #if 1 // here if I put this "#if 1" on the 5th line , qlineedit can't update , actually all widgets inside the stacedwidget can't update.
    8. stackedWidget->addWidget(imageGroupBox());
    9. stackedWidget->addWidget(textGroupBox());
    10. stackedWidget->addWidget(logGroupBox());
    11. stackedWidget->addWidget(waveGroupBox());
    12. stackedWidget->addWidget(depthGroupBox());
    13. stackedWidget->addWidget(timeGroupBox());
    14. stackedWidget->addWidget(tadpoleGroupBox());
    15. #endif
    16. return stackedWidget;
    17. }
    18.  
    19. void inti()
    20. {
    21. vlayout=new QVBoxLayout();
    22. vlayout->addWidget(listWidget);
    23. vlayout->addWidget(curveStyleLabel);
    24. vlayout->addWidget(curveStyle);
    25.  
    26.  
    27. layout=new QHBoxLayout();
    28. layout->addLayout(vlayout);
    29.  
    30. stackedWidget = buildStackedWidget(); // <----
    31. m_rightLayout = new QVBoxLayout();
    32. m_rightLayout->addWidget(stackedWidget,10);
    33.  
    34. layout->addLayout(m_rightLayout);
    35. layout->addStretch();
    36.  
    37. widget->setLayout(layout);
    38. }
    39.  
    40. QPushButton *recommendButton = new QPushButton(tr("Recommend Value"));
    41. connect(recommendButton,SIGNAL(clicked()),this,SLOT(handleRecommendValue()));
    42.  
    43. void TraceConfigDialog::handleRecommendValue()
    44. {
    45.  
    46. m_linearLeftValue->setText("testest); // <--- m_linearLeftValue is a QLineEdit
    47. m_linearLeftValue->update();
    48. stackedWidget->update();
    49. }
    To copy to clipboard, switch view to plain text mode 

    The QLineEdit is inside linearGroupBox() , which return a QGroupBox. And there is a QPushButton inside the linearGroupBox()
    Last edited by anda_skoa; 22nd March 2014 at 10:53. Reason: changed[quote] into [code] tags

  10. #10
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit can't update inside QStackedWidget

    Where m_linearLeftValue is initialized ? I think that it is initialized many times.
    P.S.
    TraceConfigDialog::handleRecommendValue() should look like :
    Qt Code:
    1. void TraceConfigDialog::handleRecommendValue()
    2. {
    3. m_linearLeftValue->setText("testest); //m_linearLeftValue is a QLineEdit
    4. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Lesiok; 22nd March 2014 at 07:15.

  11. #11
    Join Date
    Jul 2013
    Posts
    72
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QLineEdit can't update inside QStackedWidget

    I know the two lines in handleRecommendValue() is useless.

    Speaking of initializing, I do have the stackedwidget initialized many times, because I found it couldn't update. However, I have not found this trick back then, it was related to stackedwidegt' adding widgets.

  12. #12
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QLineEdit can't update inside QStackedWidget

    Your comment for the #if 1 doesn't make sense, i.e. it doesn't matter where you put it because everything between it and #endif will be part of the compiled source code.

    Qt Code:
    1. foo();
    2. #if 1
    3. bar();
    4. #endif
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. #if 1
    2. foo();
    3. bar();
    4. #endif
    To copy to clipboard, switch view to plain text mode 
    result in exactly the same code after preprocessing.

    Cheers,
    _

  13. #13
    Join Date
    Jul 2013
    Posts
    72
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QLineEdit can't update inside QStackedWidget

    anda_skoa, thanks for your replay.
    I get what you mean , it was #if 0 when I tested how many widgets to be added would cause that problem.

  14. #14
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QLineEdit can't update inside QStackedWidget

    Where is m_linearLeftValue initialised?

Similar Threads

  1. QTabWidget inside QStackedWidget
    By zgulser in forum Qt Programming
    Replies: 2
    Last Post: 21st May 2012, 09:38
  2. QLineEdit update before external method
    By Ishtar in forum Newbie
    Replies: 4
    Last Post: 19th August 2011, 19:52
  3. QLineEdit Delegate value update
    By yazwas in forum Qt Programming
    Replies: 1
    Last Post: 21st February 2011, 23:02
  4. Replies: 3
    Last Post: 25th July 2010, 19:15
  5. Access objects inside QStackedWidget widgets.
    By Trader in forum Qt Programming
    Replies: 0
    Last Post: 25th July 2010, 17:10

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.