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

How to enable the close cross in top right corner of a dialogue under Windows?



  • Hi all,

    I have a small dialogue in my qt application, which should be closable by clicking the cross in the top right corner of the dialogue window. Under Linux this is possible without any problems, but under Windows the cross is disabled. How can I enable it, so that the user can close the dialogue under Windows too? OK, he could use the ESC key, but the cross should be accessible too.

    Who can help?

    BR
    tkansgar


  • Lifetime Qt Champion

    Hi,

    What version of Qt ?
    What version of Windows ?
    How are you creating your dialog ?



  • Hi SGaist,

    you are very quick!

    @SGaist said in How to enable the close cross in top right corner of a dialogue under Windows?:

    Hi,

    What version of Qt ?

    It's Qt 5.10.1 both under Linux and Windows.

    What version of Windows ?

    Windows 10 V. 1803

    How are you creating your dialog ?

    It's a derivation from QDialog, created with new and shown with QDialog::exec().

    Do you need more Infos?

    BR
    tkansgar


  • Lifetime Qt Champion

    First thing, would it be possible to test with a more recent version of Qt ? Current is 5.12.0



  • No, we just switched to 5.10. And the application is very large. It's a commercial product. Porting it to a newer Qt version is much work. Currently there is no time for that.


  • Lifetime Qt Champion

    I'm not asking you to reconsider the version you will use to deliver your product (note that an LTS release would make more sense for that). It's to ensure that you are not chasing something that has already been fixed.

    You should rather try to build a simple dialog that reproduce the issue so that you can rule out your code doing something fishy and then you can check that small test application against a more recent version of Qt.

    Out of curiosity, what kind of porting do you expect to do when switching to a more recent version of Qt ?



  • @SGaist said in How to enable the close cross in top right corner of a dialogue under Windows?:

    I'm not asking you to reconsider the version you will use to deliver your product (note that an LTS release would make more sense for that). It's to ensure that you are not chasing something that has already been fixed.

    Do you know such a fix? If yes, I could argue, that it will be fixed in future, when we port to Qt 5.12, and had no more work with this issue.

    You should rather try to build a simple dialog that reproduce the issue so that you can rule out your code doing something fishy and then you can check that small test application against a more recent version of Qt.

    OK, but that would make work too. Get and install Qt 5.12, create, build and test the dialogue sample. I have to ask my employer.

    Out of curiosity, what kind of porting do you expect to do when switching to a more recent version of Qt ?

    The last two portings from Qt 3 to Qt 4 and then to Qt 5 made very much work. But may be porting from 5.10 to 5.12 could be less expensive. However it's not my decision.

    Sorry, I now have to go to bed. CU tomorrow again.


  • Lifetime Qt Champion

    @tkansgar said in How to enable the close cross in top right corner of a dialogue under Windows?:

    Do you know such a fix? If yes, I could argue, that it will be fixed in future, when we port to Qt 5.12, and had no more work with this issue.

    Nobody knows all the corner cases that might appear. But IF you hit a bug, the Qt developers need a minimal example to reproduce anyway.

    Just for your understanding: It's really hard to develop a library that fit's all users expectations ;)

    Regards


  • Lifetime Qt Champion

    There's no porting to be done between two version of a minor release of Qt. Forward and backward compatibility within a major series is one the of the promised the Qt framework does.


  • Lifetime Qt Champion

    Hi
    You could run the sample ( its available in Creator)
    http://doc.qt.io/qt-5/qtwidgets-widgets-windowflags-example.html

    And check out which Types and flags that goes with each other.
    ( and compare to the project )

    alt text



  • Hi all,

    many thanks for all the tips here!
    @mrjj: That sample I didn't know till now. Will use is for testing in future.
    Meanwhile I found the reason and a suitable fix for this issue: The ctor call for QDialog was this:

    QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
    

    As documented this hides the What's this button in the title bar. But unfortunately under Windows it disables the Close button too. The fix is this:

    QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint )
    

    Now the What's this button is hidden and the Close button is enabled.

    Many thanks again!
    tkansgar


Log in to reply