Results 1 to 12 of 12

Thread: Undo the this->setupId(this)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Wiki edits
    15

    Default Re: Undo the this->setupId(this)

    I have discovered that the problem is due to a "double call" to ui_->setupUi(this);
    Calling setupUi() second time should not cause any problem.

    I would need a function to disconnect all the actions of the menu (like a ui_->undoSetupUi(this) )
    To remove all the action from menu bar use
    1. QMenuBar::clear();
    or
    2. QMainWindow::setMenuBar(new QMenuBar());
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  2. #2

    Default Re: Undo the this->setupId(this)

    Quote Originally Posted by Santosh Reddy View Post
    Calling setupUi() second time should not cause any problem.


    To remove all the action from menu bar use
    1. QMenuBar::clear();
    or
    2. QMainWindow::setMenuBar(new QMenuBar());


    Thank you again for your suggestions.

    In my case the double setupUI causes that problem. I have already tried both clear() and the QMainWindow::setMenuBar(new QMenuBar()); but it doesn't work anyway.


    Maybe the problem is something else, like the setupUI that doesn't update the UI with the correct actions..

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Undo the this->setupId(this)

    Why not just hide the main window while the login dialog is shown?
    Or disable the main window while the dialog is up?

    Cheers,
    _

  4. #4

    Default Re: Undo the this->setupId(this)

    Yes, in theory I could do that, but I think it is not the right way to solve this problem (since it might happen in the future).

  5. #5
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Wiki edits
    15

    Default Re: Undo the this->setupId(this)

    Are there any warnings in the Application output when use logs in the second time?

    I suspect the problem is with connectSlotsByName().

    Try inhering the Ui form class instead of member variable.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Undo the this->setupId(this)

    I am with andy_skoa. Simple solution for a simple problem rather than trying to make a complex and awkward solution work.

    Another option would be to make the QMainWindow central widget a QStackedWidget with the login UI on one page and the logged in UI on the other... Then just flip between them.
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

  7. #7

    Default Re: Undo the this->setupId(this)

    Nope, it seems everything ok.

    Do you mean there is a bug in that Qt function?


    I've tried to inherit but I got some errors, I'll try to solve them and I'll let you know.

    Quote Originally Posted by ChrisW67 View Post
    I am with andy_skoa. Simple solution for a simple problem rather than trying to make a complex and awkward solution work.

    Another option would be to make the QMainWindow central widget a QStackedWidget with the login UI on one page and the logged in UI on the other... Then just flip between them.
    Hi, yes, maybe you're right but now, I am just interested to know why it doesn't work more than how to do it in another way.

    Thank you anyway, any point of view is welcomed

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Undo the this->setupId(this)

    Quote Originally Posted by ChrisW67 View Post
    I am with andy_skoa. Simple solution for a simple problem rather than trying to make a complex and awkward solution work.
    Indeed. Recreating widget content is almost never a good solution. The only use case where this is needed is when element existence depends on runtime value, e.g. generating n lines of an input form for n entries.

    Content specified by UI file is usually static and only created once.

    Cheers,
    _

  9. #9

    Default Re: Undo the this->setupId(this)

    Ok, I agree. Maybe mine is not the better solution.

    In fact, maybe I'll change the design anyway.... but I still would like to know why it doesn't work

Similar Threads

  1. qt undo/redo
    By giugio in forum Qt Programming
    Replies: 1
    Last Post: 12th November 2012, 16:31
  2. Syncing QTextDocument's undo stack with custom undo stack
    By Dini Selimović in forum Newbie
    Replies: 0
    Last Post: 24th June 2012, 13:11
  3. undo/redo example has refactored
    By n_vova in forum Qt Programming
    Replies: 1
    Last Post: 10th May 2012, 10:04
  4. QtableWidget UNDO
    By afro_cv in forum Qt Programming
    Replies: 15
    Last Post: 5th September 2011, 08:19
  5. buggy undo example
    By Gopala Krishna in forum Qt Programming
    Replies: 2
    Last Post: 21st August 2007, 19:33

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.