There is an issue with the deferred delete that effects the combo box.  Put a 
combo box on a dialog, and construct the dialog from an event handler.  Set and 
reset the editable property.  This will create a line edit that is then marked 
for deferred deletion at line 1563 of qcombobox.cpp in void 
QComboBox::setEditable(bool editable).  The problem is that the line edit never 
gets deleted because we are in an event handler, so it stays on the dialog box. 
 (Perhaps setting it invisible would help???)  I've replicated it on 32-bit 
Windows Vista.

This code works in Qt 4.3.4.  It also works if the combo box is on the main 
window, which made initial replication of the problem in a simple program 
tricky!

Rob


Code that replicates it:

File Main.cpp:

#include <QtGui/QApplication>
#include "testcombo.h"

int main(int argc, char *argv[])
{
        QApplication a(argc, argv);
        testcombo w;
        w.show();
        a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
        return a.exec();
}

----------------------------------------------
File testcombo.h:

#ifndef TESTCOMBO_H
#define TESTCOMBO_H

#include <QtGui/QMainWindow>
class testcombo : public QMainWindow
{
        Q_OBJECT

public:
        testcombo(QWidget *parent = 0, Qt::WFlags flags = 0);

private slots:
        void on_pushButton_clicked();
};

#endif // TESTCOMBO_H

----------------------------------------------
File testcombo.cpp:

#include <QtGui/QHBoxLayout>
#include <QtGui/QComboBox>
#include <QtGui/QPushButton>
#include <QtGui/QDialog>
#include "testcombo.h"

testcombo::testcombo(QWidget *parent, Qt::WFlags flags)
        : QMainWindow(parent, flags)
{
    QWidget *centralWidget = new QWidget(this);
    QWidget *pushButton = new QPushButton(centralWidget);
    pushButton->setObjectName(QString::fromUtf8("pushButton"));
    setCentralWidget(centralWidget);
    QMetaObject::connectSlotsByName(this);
}

void testcombo::on_pushButton_clicked()
{
        QDialog dialog;
        QComboBox *box = new QComboBox();
    box->setEditable(true);
        box->setEditable(false);
        box->addItem("test1");
        QHBoxLayout *layout = new QHBoxLayout;
        dialog.setLayout(layout);
        layout->addWidget(box);
        dialog.exec();
}

To unsubscribe - send "unsubscribe" in the subject to [EMAIL PROTECTED]

Reply via email to