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. QPushButton setIcon make application crash with no error message.

QPushButton setIcon make application crash with no error message.

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 740 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.
  • D Offline
    D Offline
    dokif
    wrote on last edited by
    #1

    Hi,
    I need to change icons of pushbuttons in my gui... i'm using this code:

    ui->NUL->setIcon(QIcon(QPixmap::fromImage(image)));
    

    where NUL is my PushButton ande image is a QImage. I've already verified the image is correctly loaded. On Qt 5.12.2 in windows with MinGW 7.3.0 32bits, that instruction SOMETIMES makes the program crash with no error message. Debugging the application says "segmentation fault" on that line, but also, no further error message to help me.

    Te same application runs perfectly on Linux compiling it with GCC. IDK what can i do to solve it, as i have no error messages.

    Any hints of what can i do to discover what is happening?

    JonBJ Pl45m4P 2 Replies Last reply
    0
    • D dokif

      Hi,
      I need to change icons of pushbuttons in my gui... i'm using this code:

      ui->NUL->setIcon(QIcon(QPixmap::fromImage(image)));
      

      where NUL is my PushButton ande image is a QImage. I've already verified the image is correctly loaded. On Qt 5.12.2 in windows with MinGW 7.3.0 32bits, that instruction SOMETIMES makes the program crash with no error message. Debugging the application says "segmentation fault" on that line, but also, no further error message to help me.

      Te same application runs perfectly on Linux compiling it with GCC. IDK what can i do to solve it, as i have no error messages.

      Any hints of what can i do to discover what is happening?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @dokif
      Please split your single line into 3 separate ones, with check for each function result. Surely it will simplify if we are sure which statement is actually segmenting, don't you think?

      1 Reply Last reply
      4
      • D dokif

        Hi,
        I need to change icons of pushbuttons in my gui... i'm using this code:

        ui->NUL->setIcon(QIcon(QPixmap::fromImage(image)));
        

        where NUL is my PushButton ande image is a QImage. I've already verified the image is correctly loaded. On Qt 5.12.2 in windows with MinGW 7.3.0 32bits, that instruction SOMETIMES makes the program crash with no error message. Debugging the application says "segmentation fault" on that line, but also, no further error message to help me.

        Te same application runs perfectly on Linux compiling it with GCC. IDK what can i do to solve it, as i have no error messages.

        Any hints of what can i do to discover what is happening?

        Pl45m4P Online
        Pl45m4P Online
        Pl45m4
        wrote on last edited by
        #3

        @dokif

        Maybe the use of QImage instead of QIcon will work?! Maybe there is something wrong with the conversion from QImage to QIcon... Just a guess...


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dokif
          wrote on last edited by
          #4

          @JonB : I've already tryed that, i can see there is content in both images and icon, and it fails anyway.

          Thanks for your answers...
          IDK why, but using the heap for storing the QImage worked for Windows. In linux it was not necessary.. I'm sure i'm making another mistake, but this works for me now.

          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