Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt QFileDialog -- proper use under OSX
Forum Updated to NodeBB v4.3 + New Features

Qt QFileDialog -- proper use under OSX

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 3.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fyngyrz
    wrote on last edited by
    #1

    QT 4.7, OSX 10.6.8

    hi. I'm using QFileDialog, and it's working in the UI sense, but on the OSX error console, I am seeing a large number of messages from OSX complaining about not having a top level window and so forth.

    QFileDialog is documented as requiring a "parent widget" to be passed to it. I've tried regular widgets, widgets that contain other widgets, the window... same console result. Clearly OSx is very unhappy, and odds are -- I hope -- that I'm doing this entirely wrong and the only reason its working is some kind of beneficent fallback mode for OSX.

    So, I've got a UI made with Qt designer. What should I pass QFileDialog in order that it work as designed? Here's my call; at the moment, "parent" is a QWidget, last try, it was "this", which would be the mainwindow object, I believe, or possibly the play QWidget that leads to opening this file, either way, same result, I've also tried it with a cached pointer to the window widget:

    @
    qbh = QDir::homePath();
    qbh += "/sdr_recordings";
    QFileDialog dialog = new QFileDialog(parent,
    tr("Load Band Recordings"),
    qbh,
    tr("Wave Files (
    .wav)"));
    @

    Here are some of the first emitted osx console errors (there are many more):

    @
    4/16/12 10:54:36 PM [0x0-0x1154153].com.yourcompany.SdrDx[11118] Mon Apr 16 22:54:36 mac-pro.local SdrDx[11118] <Error>: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID -1
    4/16/12 10:54:36 PM [0x0-0x1154153].com.yourcompany.SdrDx[11118] Mon Apr 16 22:54:36 mac-pro.local SdrDx[11118] <Error>: kCGErrorIllegalArgument: CGSDeviceCreate: Invalid window
    4/16/12 10:54:36 PM [0x0-0x1154153].com.yourcompany.SdrDx[11118] Mon Apr 16 22:54:36 mac-pro.local SdrDx[11118] <Error>: Failed to create window context device
    4/16/12 10:54:36 PM SdrDx[11118] _initWithWindowNumber: error creating graphics ctxt object for ctxt:0x2aabf, window:0xffffffff
    4/16/12 10:54:36 PM [0x0-0x1154153].com.yourcompany.SdrDx[11118] Mon Apr 16 22:54:36 mac-pro.local SdrDx[11118] <Error>: CGWindowContextCreate: failed to create context delegate.
    4/16/12 10:54:36 PM [0x0-0x1154153].com.yourcompany.SdrDx[11118] Mon Apr 16 22:54:36 mac-pro.local SdrDx[11118] <Error>: CGContextSaveGState: invalid context 0x0
    4/16/12 10:54:36 PM [0x0-0x1154153].com.yourcompany.SdrDx[11118] Mon Apr 16 22:54:36 mac-pro.local SdrDx[11118] <Error>: CGContextTranslateCTM: invalid context 0x0
    4/16/12 10:54:36 PM [0x0-0x1154153].com.yourcompany.SdrDx[11118] Mon Apr 16 22:54:36 mac-pro.local SdrDx[11118] <Error>: CGContextScaleCTM: invalid context 0x0@

    Thank you!

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fyngyrz
      wrote on last edited by
      #2

      wow, 52 views and not one reply?

      Are the file dialogs just plain broken, or is it that no one actually knows how to use them?

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        They work for me, but I usually use the "static convenience methods":/doc/qt-4.8/QFileDialog.html#static-public-members.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fyngyrz
          wrote on last edited by
          #4

          I'm not at all certain they actually work for you, in the sense that they don't produce vomit on the console. have you tried opening one of these with the system console app running? If you have, and there's no vomit, then are you using qt 4.7? Is there any precursor step you do?

          Because this call from your list of static methods...

          @
          qs = QFileDialog::getExistingDirectory(tmw,"Select Recording Directory",g_fileTarget,QFileDialog::ShowDirsOnly);
          @

          ...produces this for me:

          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID -1
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: kCGErrorIllegalArgument: CGSDeviceCreate: Invalid window
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: Failed to create window context device
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGWindowContextCreate: failed to create context delegate.
          2012-05-02 17:23:39.116 SdrDx[50123:903] _initWithWindowNumber: error creating graphics ctxt object for ctxt:0x26cf7, window:0xffffffff
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGContextSaveGState: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGContextTranslateCTM: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGContextScaleCTM: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGContextAddRect: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: doClip: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGContextRestoreGState: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID -1
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: kCGErrorIllegalArgument: CGSDeviceCreate: Invalid window
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: Failed to create window context device
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGWindowContextCreate: failed to create context delegate.
          2012-05-02 17:23:39.211 SdrDx[50123:903] _initWithWindowNumber: error creating graphics ctxt object for ctxt:0x26cf7, window:0xffffffff
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGContextSaveGState: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGContextTranslateCTM: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGContextScaleCTM: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGContextAddRect: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: doClip: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGContextRestoreGState: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID -1
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: kCGErrorIllegalArgument: CGSDeviceCreate: Invalid window
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: Failed to create window context device
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGWindowContextCreate: failed to create context delegate.
          2012-05-02 17:23:39.236 SdrDx[50123:903] _initWithWindowNumber: error creating graphics ctxt object for ctxt:0x26cf7, window:0xffffffff
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGContextSaveGState: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGContextTranslateCTM: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGContextScaleCTM: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGContextAddRect: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: doClip: invalid context 0x0
          Wed May 2 17:23:39 eight-cores-mac-pro.local SdrDx[50123] <Error>: CGContextRestoreGState: invalid context 0x0

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fyngyrz
            wrote on last edited by
            #5

            Still nothing? I guess the assumption is that Qt 4.7 is badly broken, then?

            1 Reply Last reply
            0
            • F Offline
              F Offline
              fyngyrz
              wrote on last edited by
              #6

              ho-hum, still no one. Is it that we completely lack anyone from Qt itself who knows how things actually work, or is it that they simply don't care?

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #7

                It may be that there are errors on the console here too, I didn't check and if there were any, I'd ignore them, as my programs "just work".

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  fyngyrz
                  wrote on last edited by
                  #8

                  I don't call a program that is spewing OS errors "working." Not just because the OS is obviously being used in a way it doesn't consider kosher, but also because the console is used by others as a means to determine proper operation of any number of other applications, and dumping lots of error messages out on it makes it considerably more difficult to use the console as intended.

                  I take the same approach with coding: If the compiler is producing warnings, the code isn't correct. And for the same reason. If the compiler is dumping many more-or-less "safe" warnings, it makes it a lot more difficult to see the ones I need to see, and that is uniformly a bad thing.

                  Bottom line here, either Qt is broken, or I'm using the dialog wrong. And since I'm using it the way they say to use it, I'm inclined towards Qt is broken. Further, given my experience thus far with the monumentally-busted QAudioInput and a few other things, I've begun to look for Qt problems fairly early in the debugging process.

                  1 Reply Last reply
                  0
                  • U Offline
                    U Offline
                    uranusjr
                    wrote on last edited by
                    #9

                    I didn't check every one of your errors, but many of them seem to be related with new features introduced in Lion (Versions, Mission Control, etc.). Qt 4.7 does not officially support Lion, so I guess you'll have to live with some glitches, even if they generate (non-critical) OS errors.

                    1 Reply Last reply
                    0
                    • F Offline
                      F Offline
                      fyngyrz
                      wrote on last edited by
                      #10

                      No, sorry. I don't use Lion -- it has broken multi-monitor support, and as I have six monitors, I've no interest in it. Also sandboxing, certificating, etc. Lion is a regression as far as I'm concerned.

                      I use Snow Leopard and Leopard in-house, and the errors I described here were discovered and exist under those: 10.5. and 10.6. Those are 10.6 (Snow Leopard) diagnostics in my post above.

                      What you've managed to do, however, is confirm that the Qt bug is problematic under Lion / 10.7 as well, for which I thank you. :)

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved