Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-7432

Qt designer crash on custom widget preview

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • 4.6.2
    • 4.6.0
    • Tools: Designer
    • None
    • Linux Fedora 12 x86_64
      gcc-4.4.2-20.fc12.x86_64
      Qt 4.6 (native, not fedora downloaded from Qt web site) qt-sdk-linux-x86_64-opensource-2009.05.bin
    • f6f4e2b73391dcc24382583f9c52f09bb4ced37a

    Description

      Hi,

      I'm not quit sure it's really a bug because it's my first custom widget (but usally I'm not really lucky by default).

      I had a segmentation fault when using my new Qt Widget with Qt Designer 4.6. The problem arise when trying to preview the new widget.

      when using gdb I found that the problem is in qdesigner_internal::WidgetFactory::applyStyleToTopLevel:

      Program received signal SIGSEGV, Segmentation fault.
      qdesigner_internal::WidgetFactory::applyStyleToTopLevel (style=0x0, widget=0x1829df0) at /var/tmp/qt-x11-src-4.6.0/tools/designer/src/lib/shared/widgetfactory.cpp:777
      777 /var/tmp/qt-x11-src-4.6.0/tools/designer/src/lib/shared/widgetfactory.cpp: No such file or directory.
      in /var/tmp/qt-x11-src-4.6.0/tools/designer/src/lib/shared/widgetfactory.cpp
      (gdb) bt
      #0 qdesigner_internal::WidgetFactory::applyStyleToTopLevel (style=0x0, widget=0x1829df0) at /var/tmp/qt-x11-src-4.6.0/tools/designer/src/lib/shared/widgetfactory.cpp:777
      #1 0x00007ffff7475bed in qdesigner_internal::QDesignerFormBuilder::createPreview (fw=, styleName=..., appStyleSheet=..., deviceProfile=, scriptErrors=
      0x7fffffffbee0, errorMessage=0x7fffffffc3f0) at /var/tmp/qt-x11-src-4.6.0/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp:404
      #2 0x00007ffff7476773 in qdesigner_internal::QDesignerFormBuilder::createPreview (fw=0x0, styleName=..., appStyleSheet=..., deviceProfile=..., errorMessage=0x0)
      at /var/tmp/qt-x11-src-4.6.0/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp:439
      #3 0x00007ffff7532b27 in qdesigner_internal::PreviewManager::createPreview (this=0x837f20, fw=0x1879200, pc=..., deviceProfileIndex=-1, errorMessage=0x7fffffffc3f0, initialZoom=-1)
      at /var/tmp/qt-x11-src-4.6.0/tools/designer/src/lib/shared/previewmanager.cpp:686
      #4 0x00007ffff75343cf in qdesigner_internal::PreviewManager::showPreview (this=0x837f20, fw=0x1879200, pc=..., deviceProfileIndex=-1, errorMessage=0x7fffffffc3f0)
      at /var/tmp/qt-x11-src-4.6.0/tools/designer/src/lib/shared/previewmanager.cpp:760
      #5 0x00007ffff753472f in qdesigner_internal::PreviewManager::showPreview (this=0x837f20, fw=0x1879200, style=..., deviceProfileIndex=-1, errorMessage=0x7fffffffc3f0)
      at /var/tmp/qt-x11-src-4.6.0/tools/designer/src/lib/shared/previewmanager.cpp:659

      because a null pointer was passed there:

      void WidgetFactory::applyStyleToTopLevel(QStyle *style, QWidget *widget)
      {
      const QPalette standardPalette = style->standardPalette();
      if (widget->style() == style && widget->palette() == standardPalette)
      return;
      //....
      }

      here is my widget code

      MBICInput::MBICInput(QWidget *parent) : QStackedWidget(parent)

      { displayPage = new QWidget(); displayPage->setObjectName(QString::fromUtf8("displayPage")); inputLB = new QLabel(displayPage); inputLB->setObjectName(QString::fromUtf8("inputLabel")); inputLB->setCursor(QCursor(Qt::PointingHandCursor)); addWidget(displayPage); EditPage = new QWidget(); EditPage->setProperty("EditInputLine", QVariant(true)); EditPage->setObjectName(QString::fromUtf8("EditPage")); inputInput = new QLineEdit(EditPage); inputInput->setGeometry(QRect(5, 10, 231, 25)); inputInput->setObjectName(QString::fromUtf8("input")); addWidget(EditPage); _animation = new QString(""); _message = new QString("Message"); _validator = new QRegExpValidator(QRegExp("[a-zA-Z]+"), this); }

      MBICInput::~MBICInput() {
      }

      QValidator::State MBICInput::validate(QString &text, int &pos) const{
      return _validator->validate(text, pos);
      }

      void MBICInput::paintEvent(QPaintEvent *) {
      QPainter painter(this);
      painter.setRenderHint(QPainter::Antialiasing);
      }

      QSize MBICInput::minimumSizeHint() const{
      return QSize(200, 40);
      }

      QSize MBICInput::sizeHint() const{
      return QSize(200, 40);
      }

      void MBICInput::setAnimation(const QString &animation){
      *_animation = animation;
      update();
      }

      QString MBICInput::animation() const{
      return *_animation;
      }

      void MBICInput::setMessage(const QString &message){
      *_message = message;
      update();
      }

      QString MBICInput::message() const{
      return *_message;
      }

      void MBICInput::mousePressEvent(QMouseEvent *event){
      if(currentIndex()==0){
      setCurrentIndex(1);
      }else{
      setCurrentIndex(0);
      }
      update();
      }

      I tried the same code with the fedora Qt version 4.5.3-9 and it worked just fine.

      you will find my entire code in attachement.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            chedi chedi toueiti
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes