Results 1 to 10 of 10

Thread: menuBar() Problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: menuBar() Problem

    Dont know why your application is crashing.. I tried the menu with QMenuBar pointer too... and its still working fine for me...
    also from source code, menuBar creates a menubar if it doesnt exist..

    Qt Code:
    1. QMenuBar *QMainWindow::menuBar() const
    2. {
    3. QMenuBar *menuBar = qobject_cast<QMenuBar *>(d_func()->layout->menuBar());
    4. if (!menuBar) {
    5. QMainWindow *self = const_cast<QMainWindow *>(this);
    6. menuBar = new QMenuBar(self);
    7. self->setMenuBar(menuBar);
    8. }
    9. return menuBar;
    10. }
    To copy to clipboard, switch view to plain text mode 

    I suggest one thing... catch the closEvent for your window... and trace back as to what caused it... it will give an idea why ur program is crashing...

    by the way, by your crash, I guess it means ur application closes without any error ?? right ?

  2. #2
    Join Date
    Jan 2007
    Location
    Augsburg, Germany
    Posts
    75
    Thanks
    4
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: menuBar() Problem

    What about building your application and Qt in debug mode and stepping through?
    (hope thats not too difficult for you)

  3. #3
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    38
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: menuBar() Problem

    Quote Originally Posted by aamer4yu View Post
    I suggest one thing... catch the closEvent for your window... and trace back as to what caused it... it will give an idea why ur program is crashing...

    by the way, by your crash, I guess it means ur application closes without any error ?? right ?
    Hi Gri,
    Quote Originally Posted by gri View Post
    What about building your application and Qt in debug mode and stepping through?
    What do you mean ? I couldnt understand ..?

    Hi Aamer4yu,

    My application constructs under Qt 3.3.4 on Windows XP.
    While trace I got the following error.
    "Unhandled exception in xxxxxx.exe: Access Violation" ://QMenuBar* mnu = menuBar(); is raising this error. menuBar() returns NULL value. How to handle that case.?

    It became hectic to me.. Please help me..
    WINNERS DON`T D DIFFERENT THINGS THEY D THINGS differently.

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: menuBar() Problem

    I am not famliar with Qt 3...

    neways I have few doubts...
    1) where are you calling setMainMenu() function ??
    2) what is mainwindow derived from ?
    3) are u trying to enable / disable menu from setMainMenu function, or are u tryung to create a menu ??

    rest i agree with gri.... u should step thru ur code...
    ie. moving line by line in ur code, while debugging it...

    also can u post a minimal example showing the problem u r facing ?

Similar Threads

  1. Replies: 2
    Last Post: 12th November 2006, 08:47
  2. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  3. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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
  •  
Qt is a trademark of The Qt Company.