Results 1 to 4 of 4

Thread: Expected behavior of Qt::Tool style?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Expected behavior of Qt::Tool style?

    What happens if you pass Qt::Tool directly to the QDialog constructor (i.e. QDialog(parent, Qt::Tool)) instead of setting it after construction?

    I do not remember seeing a modal tool window in any GUI. Maybe this unusual pattern was not considered or tested in Qt.

    On a side note, instead of QScopedPointer<Poppy> theBox(new Poppy(this)); you could simply allocate the Poppy on the stack (assuming you do want a modal dialog).

  2. #2
    Join Date
    Apr 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Expected behavior of Qt::Tool style?

    Setting it in the constructor does fix it, though it causes the dialog window to be hidden after alt-tabbing. I've seen other threads about that though, with some resolutions. Also, I'll look into your other suggestions after work and see if there's an overall better solution for this widget.

    Out of curiosity without digging into internals, do you know why setting it in the parent constructor would matter? I'd expect a setter and a constructor to have the same end-result.

    Thanks.

  3. #3
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Expected behavior of Qt::Tool style?

    Quote Originally Posted by Valistar View Post
    Out of curiosity without digging into internals, do you know why setting it in the parent constructor would matter? I'd expect a setter and a constructor to have the same end-result.
    I do not know about the internals either, and only relied on what I could find in the documentation, which I find to be somewhat lacking on this particular topic. For instance, the flags passed to the QDialog constructor default to 0, but the documentation states that the non-zero Qt::Dialog flag is on for QDialog by default. This leads me to suspect that the QDialog constructor adds some (unspecified) flags on its own, and that subsequently calling QWidget::setWindowFlags() may clear them. Maybe passing Qt::Tool to the constructor is actually equivalent to calling dialog->setWindowFlags(dialog->windowFlags() | Qt::Tool) afterwards, but this is a mere conjecture.

    Secondly, QWidget::setWindowFlags() warns about setParent() being called, and I admit being suspicious of the effects that might have on a QDialog (whose documentation mentions the Qt::Dialog flag being cleared on that occasion).

Similar Threads

  1. Replies: 3
    Last Post: 1st October 2014, 05:29
  2. Qt Creator A tool for coding style analysis of C/C++ in Qt Creator
    By Slazer in forum Qt Tools
    Replies: 0
    Last Post: 21st September 2012, 20:22
  3. Behavior not expected by QDoubleValidator()
    By vcp in forum Qt Programming
    Replies: 8
    Last Post: 3rd February 2011, 11:15
  4. Style sheets bug? Or normal behavior?
    By Syntho in forum Qt Programming
    Replies: 0
    Last Post: 7th June 2010, 09:16
  5. Grouping of Tool buttons in Tool bar
    By febil in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2009, 11:51

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.