Results 1 to 4 of 4

Thread: Problem with applying old values to interface items

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2011
    Posts
    2
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Problem with applying old values to interface items

    Hello everybody!
    I am new to QT, probably i'm missing some basic concept, i wrote a simple demo app (windows/mingw), i am trying to change caption on push button, it works for the first time, but if i'm trying to set old value after that - it doesn't. Here are some examples:

    Qt Code:
    1. this->ui.pushButton->setText("1");
    2. this->ui.pushButton->setText("2");
    3. this->ui.pushButton->setText("3");
    To copy to clipboard, switch view to plain text mode 

    this works fine, the value displayed on button is "3".

    Qt Code:
    1. this->ui.pushButton->setText("1");
    2. this->ui.pushButton->setText("2");
    3. this->ui.pushButton->setText("1");
    To copy to clipboard, switch view to plain text mode 

    This example doesn't work as i expect - the displayed value on the button is "2".


    similar situation with other properties, for example:

    Qt Code:
    1. this->ui.spinBox->setEnabled(true);
    2. this->ui.spinBox->setEnabled(false);
    3. this->ui.spinBox->setEnabled(true);
    To copy to clipboard, switch view to plain text mode 

    the element stays in "disabled" state.

    i tryed to call update() after each property change for the particular element - that didn't help.

    Any suggestions? what am i missing here?
    Thank you all in advance.

  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: Problem with applying old values to interface items

    For me this code

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <QLabel>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. QLabel w;
    8. w.setText ("1");
    9. w.setText ("2");
    10. w.setText ("1");
    11. w.show();
    12.  
    13. return a.exec();
    14. }
    To copy to clipboard, switch view to plain text mode 

    ad this

    Qt Code:
    1. Widget1::Widget1(QWidget *parent) :
    2. QWidget(parent),
    3. ui(new Ui::Widget1)
    4. {
    5. ui->setupUi(this);
    6.  
    7. ui->loadInfoButton->setText ("1");
    8. ui->loadInfoButton->setText ("2");
    9. ui->loadInfoButton->setText ("1");
    10. }
    To copy to clipboard, switch view to plain text mode 

    work fine.

    What Qt version are you using?
    A camel can go 14 days without drink,
    I can't!!!

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

    sergee (8th July 2011)

Similar Threads

  1. Replies: 1
    Last Post: 23rd April 2011, 17:33
  2. Replies: 3
    Last Post: 22nd August 2010, 09:23
  3. Problem with design interface
    By tux-world in forum Newbie
    Replies: 5
    Last Post: 10th March 2010, 14:19
  4. Replies: 8
    Last Post: 1st October 2009, 10:07
  5. Problem applying setWindowOpacity to a custom Widget
    By yellowmat in forum Qt Programming
    Replies: 8
    Last Post: 1st November 2006, 10:05

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.