2

I'm working with the Qt KDE Necessitas project. I have a project built in Qt Creator and I am installing the apk on an emulator API-15 (also tested on API-10).

The following code is setup to clear the text of two different QLineEdit objects when a button is clicked, but this isn't the case. Randomly, only one of the two QLineEdit objects are cleared.

mainwindow.h:

class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    explicit MainWindow(QWidget *parent = 0);
public slots:
    void slotClear();

private:
    QLineEdit* line1;
    QLineEdit* line2;
//...
};

mainwindow.cpp:

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QVBoxLayout* mainLayout = new QVBoxLayout;

    QFormLayout* form = new QFormLayout;
    line1 = new QLineEdit;
    form->addRow(tr("Line 1: "), line1);
    line2 = new QLineEdit;
    form->addRow(tr("Line 2:"), line2);

    QPushButton* button = new QPushButton;
    mainLayout->addLayout(form);
    mainLayout->addWidget(button);

    QWidget* centralWid = new QWidget(this);
    centralWid->setLayout(mainLayout);
    this->setCentralWidget(centralWid);

    connect(button, SIGNAL(clicked()), this, SLOT(slotClear()));
}

void MainWindow::slotClear()
{
    line1->clear();
    line2->clear();
}
//...

Calling the function QLineEdit::setText("") produces the same results. Additionally, connecting the clicked() signal from the button directly to the clear() slot of the QLineEdit has no effect.

I haven't been programming in Qt for very long, so I am unsure if there is something I am doing wrong. Is anybody seeing something needs to be corrected in order to have the text cleared from BOTH QLineEdits? I am not sure if this is unique to Qt itself or Qt Necessitas. Any input would be greatly appreciated.

EDIT

I have also just noticed that entering text in one line, switching to another line and entering text there, and then switching back to the original line results in the original text being erased once the field is clicked (note, the button was never clicked). I think this is a pretty clear indication that something funky is going on.

EDIT 2

Registered as a bug with KDE

Chris Dargis
  • 5,891
  • 4
  • 39
  • 63

0 Answers0