简体   繁体   中英

Application crashes on setupUi in QLineEdit consturctor only in MacOS

I have a Qt4.8 QWidget with generated Ui_ file

class QMyWidget: public QWidget
{
Q_OBJECT
public:
    Ui_MyGeneratedUi ui;
    ...
}

It works fine on Windows and Linux, but when I try to

QMyWidget() {
    > ui.setupUi(this);
    ...
}

on MacOS (10.12) my application crashes with stack trace looking like this or this . There seems to be nothing particularly suspicious in UI. Moreover there are many other QWidgets in my application with generated UI and QLineEdit insed which work well on MacOS too.

Mentioned bugs are closed and seem to be amended in Qt5 but I wonder what is the reason of these crashed and if there is any workaround.

This bug is very cryptic. In my case it was triggered by several QLabels in both parent and child QWidget with inside which were used as buttons

QLabel* sample = new QLabel("<a href=\"dothething\">Do thing</a>", ui.protoarea);
QObject::connect(
        sample, SIGNAL(linkActivated(QString)),
        this, SLOT(add_clicked(QString))
);

as soon as I replaced them with actual buttons everything started working. There seems to be a glitch in logic which element should be focused at adding new widget.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM