Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QDialog does not sense click when argument are passed



  • Hello everyone,
    I'm facing a really strange problem. I'm developing an application for linux embedded platform (imx6 0659). I already designed a lot of window which are working correctly. Some of them are created passing some argument in the constructor (es. Anagrafica(QWidget *parent, QString sNewpat, bool bSelection)) and they are all working fine. Now I added a new window to the project, by now I only added a qpushbutton to go back (this->reject), but, if I change the constructor of this window passing any argument, as already done for some other window of the project, this window (which is ApplicationModal like the others) doesn not work correctly: it is impossible to click button and go back (click is not sensed). If I remove the argument in the constructor, the button works correctly (so, the window is sensing click).
    I'm pretty sure I created this new window like all the others, this thing is very strange to me!
    Any help would be really apprecieated!
    marco Chiesi


  • Lifetime Qt Champion

    @MarcoChiesi79 What is this parameter and how is it used? How do you create the instance of that window (actually dialog, right?)?



  • @jsulm Hi,
    it's not a matter of parameter type, or how I'm using it. Any parameter, even if not used, give the problem.
    Window is a normal Ui window opened throug exec().
    By now, I solved changing window type from ApplicationModal to WindowModal, and this for me is good too, because now the window works as it should and it is not possible to click the calling window as I wanted.
    What I do not understand now, is why other windows of the project, called and created in the same way, passing arguments in the constructor, can be ApplicationModal without giving similar problem.
    Surely I do not understand this because I'm a newbie
    Thank you for answering!
    Marco Chiesi


  • Lifetime Qt Champion

    @MarcoChiesi79 Well, I don't understand that either. Without more information and/or code it is hard to say.



  • I did not find ant other solution than using WindowModal, so I can consider this matter solved, at least for my needs



  • @MarcoChiesi79

    Your description was not very helpful. If you show, what you did there, maybe we can find a solution. Could be a simple beginner's mistake.
    It's impossible that your QDialog doesnt work anymore, only because you've passed some addiitional stuff in your constructor.



  • @Pl45m4 said in QDialog does not sense click when argument are passed:

    @MarcoChiesi79

    Your description was not very helpful. If you show, what you did there, maybe we can find a solution. Could be a simple beginner's mistake.
    It's impossible that your QDialog doesnt work anymore, only because you've passed some addiitional stuff in your constructor.

    I can understand your remark. I'll try to explain better what happens in this way:
    MainWindow -> ApplicationModal window (with argument): everything work fine
    MainWindow -> ApplicationModal window (with argument)-> ApplicationModal window (withargument): does not work and should be changed in
    MainWindow -> ApplicationModal window (with argument) ->WindowModal (with argument)

    It seems that the problem appears when you open an ApplicationModal window from an ApplicationModal window. My need is to open window and force the user to interact with it and close it to interact with previous window, so WindowModal is good enough for this


  • Lifetime Qt Champion

    Hi,

    So you have a modal dialog within a modal dialog ?

    This sound a bit bad design wise. In any case, are you calling exec for both dialogs ? If so, you should move to the use of the open method.



  • @SGaist said in QDialog does not sense click when argument are passed:

    Hi,

    So you have a modal dialog within a modal dialog ?

    This sound a bit bad design wise. In any case, are you calling exec for both dialogs ? If so, you should move to the use of the open method.

    I confirm that I'm using exec for both dialogs, since my goal is to force the user to interact with the dialog before interacting again with the previous one. I will take care of your suggestion to use open method.
    By the way, I would like to please you to explain better your remark about the design: what's wrong in having a cascade of windows which allow user to interact only with the current one? That's what I want for the application I'm writing.
    Thank you for your comprehension and patience


  • Lifetime Qt Champion

    It's not the fact that you need "modal" operations in sequence, it's really just the modal dialog within a modal dialog.

    Not knowing the logic behind your decision, I can't really say more. It might be worth drawing the flow of that logic to see whether it would maybe make more sense to have a wizard or possibly a state machine to model the sequence of actions.



  • @SGaist said in QDialog does not sense click when argument are passed:

    It's not the fact that you need "modal" operations in sequence, it's really just the modal dialog within a modal dialog.

    Not knowing the logic behind your decision, I can't really say more. It might be worth drawing the flow of that logic to see whether it would maybe make more sense to have a wizard or possibly a state machine to model the sequence of actions.

    I could resume in this way. MainWindow load some settings parameters from a file and load it into an object which has one member for each parameter. I open Settings window passing a reference to the object. In the constructor of the Settings window I set all the parameter coming from main to an object which is a member of Setting window (m_parameter.parameter1 = theparameter->parameter1 and so on...). I want that user can change some of the parameter in Setting window and some of the parameter in a child window (let's call it Setting2), so I repeat the operation passing the member of Setting as reference to Setting2 and in the constructor I repeat assignment. obviously, if the user if changing parameter in Setting2, he should not interact with Setting window. This is what I would like to reach with my application.
    Thank you for your interest to this!


  • Lifetime Qt Champion

    Why not separate things like it's done in e.g Qt Creator preferences ?

    No need for two dialogs. A QListWidget to select which set of parameters to edit and and QStackedWidget to show the corresponding editor. Thus, no need for multiple copies of your parameters object.



  • @SGaist

    Well noted! Thank you for the suggestion!


Log in to reply