Results 1 to 20 of 28

Thread: how to launch a wizard from the mainwindow's File Menu

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2013
    Posts
    25
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: how to launch a wizard from the mainwindow's File Menu

    That was meant to address aamer4yu's concerns for me not posting the whole code.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to launch a wizard from the mainwindow's File Menu

    But that code differs from what you posted in #1. So which one is correct, which class is the main window and which is not?

    Anyway, your vanishing window problem comes from the already mentioned twice problem that you are allocating the window on the stack that unwinds immediately after the function completes its course.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2013
    Posts
    25
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: how to launch a wizard from the mainwindow's File Menu

    The code at #6 is meant to launch my SkoolCalcWizard and i wrote it way before i wrote the mainwindow.cpp code, its basically the execution part in main.cpp to confirm that my wizard actually runs. So i posted that to reassure aamer4yu that i needn't post the whole of my SkoolCalcWizard.cpp code here since the wizard's code is tight. It isn't really important in this context.
    So the original question is at #1.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to launch a wizard from the mainwindow's File Menu

    I have already told you that code from post #1 is correct apart from compilation issues and a memory leak. The first snippet from #3 is also fine provided that the exec method is a regular QDialog::exec() call.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Sep 2013
    Posts
    25
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: how to launch a wizard from the mainwindow's File Menu

    So what do i do exactly cause thats why am here, that's where i got stuck. I do not know how to resolve the memory leak problem??

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to launch a wizard from the mainwindow's File Menu

    Unless you post some minimal example reproducing the problem, we can't help you as the code you initially posted is not the source of the problem. If that's your actual code of course and not something that only resembles your code.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Sep 2013
    Posts
    25
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: how to launch a wizard from the mainwindow's File Menu

    If what i posted isn't the problem then what is? Because i don't really know how to go about anymore.

    Like i said my wizard works fine, it launches yes and thats why i posted the code at #6. I am now looking for a way to launch it from my mainwindow when i click New from my mainwindow's File Menu.

    The mainwindow also launches successfully and has all the File menu actions like New, Open, Save, Save As, etc defined but i chose to only post the definition for New implemented in MainWindow::newFile() here cause i thought i could change it to suit my needs.

    I also showed how New is connected to newFile() in the function MainWindow::createActions() which i originally posted in the first post.

    So i really don't know what you want more, all i'm asking is if there's some alternative way i could change the portions of the code snippets i posted to suit my needs because that's where i am stuck, because there's a memory leak so my method is apparently wrong, isn't there an alternative.

    Both the wizard and the mainwindow launch when you run one and then change the code to run the other, in main.cpp so how would you connect the two so that they launch the way i want ??

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to launch a wizard from the mainwindow's File Menu

    Quote Originally Posted by pkjag View Post
    If what i posted isn't the problem then what is?
    No idea, we're yet to see some compilable example reproducing the problem.

    I am now looking for a way to launch it from my mainwindow when i click New from my mainwindow's File Menu.
    Code in post #1 does that (once you fix compilation errors).

    So i really don't know what you want more
    We want a (1) minimal (i.e. max 50 lines of code), (2) compilable (i.e. creating a launchable executable) example (3) reproducing the problem (i.e. demonstrating what doesn't work).


    all i'm asking is if there's some alternative way i could change the portions of the code snippets i posted
    What you posted should work fine.

    because there's a memory leak
    Do you know what a memory leak is and how to fix one?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Sep 2013
    Posts
    25
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: how to launch a wizard from the mainwindow's File Menu

    I know what a memory leak is but can't figure out how to fix one.

    I already modified code in #1 to #3 and so there's no compilation error just runtime error.
    So seems like the memory leak is the culprit since the code compiles just fine it just doesn't produce output that behaves as well

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to launch a wizard from the mainwindow's File Menu

    Quote Originally Posted by pkjag View Post
    I know what a memory leak is but can't figure out how to fix one.
    Delete the object causing the leak once you don't need it anymore or use some mechanism (like Qt's parent-child relationship or the signal-slot mechanism together with deleteLater() slot) that will do that for you.

    I already modified code in #1 to #3 and so there's no compilation error just runtime error.
    So unmodify the code to have what you had in #1 minus compilation errors.

    So seems like the memory leak is the culprit
    So you don't know what a memory leak is after all, do you?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Sep 2013
    Posts
    25
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: how to launch a wizard from the mainwindow's File Menu

    Not in this context i just vaguely understand it like in assembly i.e a stack overflow.

    What object is causing the leak and in what file should i delete it??

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to launch a wizard from the mainwindow's File Menu

    Quote Originally Posted by pkjag View Post
    Not in this context i just vaguely understand it like in assembly i.e a stack overflow.
    Stack overflow has nothing to do with memory leaks.

    What object is causing the leak and in what file should i delete it??
    http://lmgtfy.com?q=memory+leak
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Sep 2013
    Posts
    25
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: how to launch a wizard from the mainwindow's File Menu

    So i figured that the object causing the memory leak is SkoolCalcWizard wizard but i don't understand why cause i already replaced the pointer notation with the normal object declaration in #3.

    And i do use the object by calling show or return since i have already used both of these functions and they both make my program vanish.

    So i'd like if you could spell it out for me like explicitly.
    Last edited by pkjag; 5th September 2013 at 15:27.

Similar Threads

  1. how to add my menu class to my MainWindow?
    By saman_artorious in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2012, 21:27
  2. Replies: 1
    Last Post: 29th September 2011, 11:14
  3. Launch app by opening a file
    By Windsoarer in forum Qt Programming
    Replies: 2
    Last Post: 28th May 2009, 06:22
  4. Replies: 1
    Last Post: 13th May 2009, 03:18
  5. MainWindow Menu bug in Qt 4.2.3?
    By No-Nonsense in forum Qt Programming
    Replies: 4
    Last Post: 11th March 2007, 11:47

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.