[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyKDE] QClipboard Problem
From:       Doug Bell <dougb () bellz ! org>
Date:       2006-08-21 12:45:49
Message-ID: 20060821124549.GA9638 () bellz ! org
[Download RAW message or body]

Phil Thompson wrote:
> On Tuesday 25 July 2006 12:12 pm, Doug Bell wrote:
> > Hi -
> >
> > I'm having problems with QClipboard's dataChanged() signal in PyQt4 on
> > Windows.  It works fine during program execution, but the program
> > crashes at exit if the contents of the clipboard had been changed with
> > the signal connected.
> >
> > I'm not sure whether this is a bug in PyQt or Qt, but, since I couldn't
> > find anything about it in the Qt mailing list, I'm trying here.  Also,
> > this bug does not occur in Linux.
> >
> > A short example that produces the problem is attached.  If the button is
> > pressed during the run, the program crashes at exit.
> >
> > I'm using the latest binary builds for Windows - Python 2.4.3, Qt 4.1.4
> > and PyQt 4.0.1.
> 
> I've been playing with this but can't get to the root of the problem. The 
> crash is happening in the QApplication dtor and I'm beginning to suspect that 
> it is a Qt bug.
> 
> I'd be interested in playing with your C++ version. You might try explicitly 
> deleting the button then the QApplication just before returning from main(). 
> This would more closely mimic what PyQt is doing.

I changed the C++ version to delete the widget and the application
before exit, but it still doesn't duplicate the crash of the PyQt
version.

I attached the C++ files for you to play try.

Thanks,
Doug.

["tst.h" (text/x-chdr)]

#include <QWidget>

class MyWidget : public QWidget
{
    Q_OBJECT
public:
    MyWidget(QWidget *parent = 0);
public slots:
    void copyClip();
    void checkChange();
};


["tst.cpp" (text/x-c++src)]

#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QVBoxLayout>
#include <QClipboard>
#include <QMessageBox>

#include "tst.h"

MyWidget::MyWidget(QWidget *parent)
    : QWidget(parent)
{
    QPushButton *cp = new QPushButton("Copy Text");

    connect(cp, SIGNAL(clicked()), this, SLOT(copyClip()));
    connect(QApplication::clipboard(), SIGNAL(dataChanged()),
            this, SLOT(checkChange()));

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(cp);
    setLayout(layout);
}

void MyWidget::copyClip()
{
    QClipboard* clip = QApplication::clipboard();
    clip->setText("Test Text");
}

void MyWidget::checkChange()
{
    QMessageBox::information(0, "Here", "Changed");
}

int main(int argc, char *argv[])
{
    QApplication *app = new QApplication(argc, argv);
    MyWidget *widget = new MyWidget;
    widget->show();
    int result = app->exec();
    delete widget;
    delete app;
    return result;
}


_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic