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. Image manipulation in Qt console app segfaults?

Image manipulation in Qt console app segfaults?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.9k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    MWPau
    wrote on last edited by
    #1

    Hi all,

    Can someone tell me why the following creates a segfault?
    It does so at the drawText line.

    @
    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv, QApplication::Tty);

    QImage img(800, 800, QImage::Format_RGB16);
    QPainter painter(&img);
    
    QFont font("utsaah", 50, QFont::Bold, true);
    painter.setPen(QPen(Qt::white));
    painter.setFont(font);
    
    painter.drawText(0,0, 200,200, Qt::AlignLeft, "blah");
    
    return 0;
    

    }
    @

    Is there any way i can make this work without it needing to become a Qt GUI app?

    Thanks in advance.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Soraltan
      wrote on last edited by
      #2

      Hi,

      what do you mean by "... become a Qt GUI app" or a "... Qt console app"? When you create Qt Console project with the QtCreator your pro-file has a

      @QT -= gui@

      in which case the code given does not compile, because QApplication, QPainter and QImage are not available.

      So, do you want to avoid creating a QWidget of any kind? That should be no problem. In fact, when commenting the above line

      @#QT -= gui@

      I can compile your code and execute it without any problems.

      Best Soraltan

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MWPau
        wrote on last edited by
        #3

        I should mention this is qt-embedded.

        It segfaults if i use:
        @
        QApplication app(argc, argv, QApplication::Tty);
        @

        But if i use this it works fine (but i dont want the extra weight of the QWS/GUI).
        @
        QApplication app(argc, argv);
        @

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Soraltan
          wrote on last edited by
          #4

          Then I'm out, sorry. Not worked with Qt-embedded yet.

          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