Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]How to show *.dxf or *.dwg files on QGraphicsScene ?
QtWS25 Last Chance

[Solved]How to show *.dxf or *.dwg files on QGraphicsScene ?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 5 Posters 12.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ashokb
    wrote on last edited by
    #1

    Hi,
    In my app i am using QGraphicsScene to show an image.
    I want to overlap CAD drawing onto this image so that user can visually inspect.

    The CAD files are in the *.dxf or *.dwg format.

    Currently i am able to overlap *.png image on my image as
    @
    QPixmap pixx("C:/Users/Public/Pictures/Sample Pictures/tulips.jpg");
    scene->addPixmap(pixx);
    @

    My question is,
    How to add cad drawings on scene? OR
    Is there any other way to do this?

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Qt doesnot support the above format. Check "supported formats":http://qt-project.org/doc/qt-5/QPixmap.html#reading-and-writing-image-files
      You will need to render the above drawings to Qt supported image formats externally.

      157

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ashokb
        wrote on last edited by
        #3

        So it means i cannot use .dxf/.dwg directly with QPixmap, QGraphicsScene.

        Is there any way in qt with which i can convert these formats to supported formats ?
        OR
        Any way other than QPixmap, QGraphicsScene to overlap CAD drawing on image and show on GUI ?

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          [quote author="ashokb" date="1410680851"]So it means i cannot use .dxf/.dwg directly with QPixmap, QGraphicsScene.

          Is there any way in qt with which i can convert these formats to supported formats ?
          OR
          Any way other than QPixmap, QGraphicsScene to overlap CAD drawing on image and show on GUI ?[/quote]

          You need to write your own parser for those file formats, or use an external library if available.

          Regarding your second question: no, there is no class in Qt that understands CAD files.

          (Z(:^

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tilsitt
            wrote on last edited by
            #5

            Hi,

            If you're dealing with CAD data, I guess we speak about 3D data, are'nt we? Anyway, QPixmap -- and other image classes in Qt -- are designed for bitmaps, not vector graphics. Qt only supports SVG format for vector graphics. You can take a look at the sources of the corresponding classes -- starting with "QGraphicsSvgItem":http://qt-project.org/doc/qt-5/qgraphicssvgitem.html -- to see how you can add dxf or dwg support, but I guess it will be about sub-classing QGraphicsItem and reimplement "paint()":http://qt-project.org/doc/qt-5/qgraphicsitem.html#paint. Using the QPainter passed as argument, you will be able to draw the primitives of your file -- you will have to implement a parser to load it.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              ashokb
              wrote on last edited by
              #6

              Hi,
              Alright qt doesn't support .dxf/.dwg files, but it supports activex.
              I have decided to use api for liteCAD and to access its few functions directly in my app.

              Thanks to all...

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                Just for the record: The developers of "QCAD":http://www.qcad.org/ (which is written in Qt) have published their dxf library "dxflib":http://www.ribbonsoft.com/en/what-is-dxflib under the GPL.

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  Just for the record: The developers of "QCAD":http://www.qcad.org/ (which is written in Qt) have published their dxf library "dxflib":http://www.ribbonsoft.com/en/what-is-dxflib under the GPL.

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved