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] If want to copy, application crashes
Forum Updated to NodeBB v4.3 + New Features

[Solved] If want to copy, application crashes

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 700 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.
  • F Offline
    F Offline
    fant
    wrote on last edited by
    #1

    Hello,

    I have a problem thats eventually easy for profis, but not for me. :(
    In my mainwindow there is an widget attribute (area), that contains an special textedit (class Editor inherits from QTextEdit). I want to call the copy method of Editor via action element in menubar of mainwindow.

    @
    void MainWindow::copy() {
    this -> area -> getEditor() -> copy();
    }
    @

    Here is my getter method for the editor attribute (that's private):

    @
    Editor *getEditor() { return editor; }
    @

    If I run my window and click on action element for copy, the application crashes. Debugger says this:
    "Stopped by Exception at 0x509b6bda, code: 0xc0000005; read access violation at: 0x0, flags=0x0 (first chance).
    I don't know, what I doing wrong. Please help me. :(

    1 Reply Last reply
    0
    • T Offline
      T Offline
      thEClaw
      wrote on last edited by
      #2

      Use the debugger and find out if any of these is not what you expect:
      @void MainWindow::copy() {
      this;
      this->area;
      this->area->getEditor();
      this->area->getEditor()->copy();
      }@

      Go through it line by line and look where it crashes. Then you will know if an object is not initialized. The code you posted doesn't look fundamentally wrong, the error is probably created somewhere else.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fant
        wrote on last edited by
        #3

        Thank you for help! :)

        Search was successful! :)
        I created editor-variable local, not as global attribute. So the attribute was null of course. :D

        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