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

QGraphicsTextItem in non-gui application will crash

    XMLWordPrintable

Details

    • aefda8ce30695c5383860eab709acca345d290dc

    Description

      Using QGraphicsTextItem in non-gui application will result Segmentation fault. This happens because the cursor width is set based on the application style and non-gui application does not have a style.

      The following code reproduces the problem:

      int main(int argc, char *argv[])
      {
      QApplication app(argc, argv, false);

      QImage image(200, 200, QImage::Format_ARGB32);
      QPainter painter(&image);

      QGraphicsTextItem item;
      item.setHtml("<b>Graphics</b> item");
      QStyleOptionGraphicsItem opt;
      opt.state = QStyle::State_None;
      item.paint(&painter, &opt, 0);

      painter.end();

      image.save("test.png");
      return 0;
      }

      Attachments

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

        Activity

          People

            smd Jan Arve
            qtcomsupport Qt Support
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes