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. How to implement OCX functions

How to implement OCX functions

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.9k Views 2 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.
  • B Offline
    B Offline
    borisa
    wrote on last edited by
    #1

    Hi

    i want to insert to my code the follow function

    • (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center
      shouldPresentNotification:(NSUserNotification *)notification
      {
      return YES;
      }
      (http://cocoathings.blogspot.co.il/2013/01/introduction-to-user-notifications-in.html)
      How can i do it?
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      What sort of code do you mean?
      It seems to be used to inform the system that Notification should be
      shown.

      Reading this
      http://stackoverflow.com/questions/22142592/mac-os-usernotificationcenter-in-qt

      Gives idea of how is constructed.

      MyClass::MyClass()
      {
          id<NSUserNotificationCenterDelegate> self = (id<NSUserNotificationCenterDelegate>)this;
          [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self]; 
      }
      
      BOOL MyClass::shouldPresentNotification(NSUserNotificationCenter *center, NSUserNotification *notification)
      {
          return YES;
      }
      
      void MyClass::test()
      {
        NSUserNotification *userNotification = [[[NSUserNotification alloc] init] autorelease];
        userNotification.title = @"Title";
        userNotification.informativeText = @"Test message";
        [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification];
      }
      
      B 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        What sort of code do you mean?
        It seems to be used to inform the system that Notification should be
        shown.

        Reading this
        http://stackoverflow.com/questions/22142592/mac-os-usernotificationcenter-in-qt

        Gives idea of how is constructed.

        MyClass::MyClass()
        {
            id<NSUserNotificationCenterDelegate> self = (id<NSUserNotificationCenterDelegate>)this;
            [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self]; 
        }
        
        BOOL MyClass::shouldPresentNotification(NSUserNotificationCenter *center, NSUserNotification *notification)
        {
            return YES;
        }
        
        void MyClass::test()
        {
          NSUserNotification *userNotification = [[[NSUserNotification alloc] init] autorelease];
          userNotification.title = @"Title";
          userNotification.informativeText = @"Test message";
          [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification];
        }
        
        B Offline
        B Offline
        borisa
        wrote on last edited by
        #3

        Hi,

        I can not declare in my H file follow line
        BOOL MyClass::shouldPresentNotification(NSUserNotificationCenter *center, NSUserNotification *notification)
        because if i add the follow line i got compilation error
        #include <Foundation/NSUserNotification.h>

        My pro file:
        QT += core gui
        TARGET = untitled
        TEMPLATE = app
        LIBS += -framework Foundation
        INCLUDEPATH +=/System/Library/Frameworks/CoreFoundation.framework/Versions/C/Headers
        SOURCES += main.cpp
        HEADERS += mainwindow.h
        mac
        {
        OBJECTIVE_HEADERS +=mainwindow.h
        OBJECTIVE_SOURCES +=mainwindow.mm
        }

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          hi
          I dont have a mac to test on
          does
          "/System/Library/Frameworks/CoreFoundation.framework/Versions/C/Headers"
          contain
          Foundation
          and in there
          NSUserNotification.h ?

          1 Reply Last reply
          0
          • B Offline
            B Offline
            borisa
            wrote on last edited by
            #5

            Not sure

            1 Reply Last reply
            0
            • B Offline
              B Offline
              borisa
              wrote on last edited by
              #6

              I got error - expected unqualified - id, ....
              Unknown type name 'NSString'

              How can i fix it?

              mrjjM 1 Reply Last reply
              0
              • B borisa

                I got error - expected unqualified - id, ....
                Unknown type name 'NSString'

                How can i fix it?

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #7

                @borisa said:

                NSString

                well u must find the .h file where its defined and include it.
                update:
                seems to be something else than pure .h file
                http://stackoverflow.com/questions/4497378/foundation-framework-no-nsstring-h-file
                so might be your XCode setup or SDK.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi,

                  Are you planning to use Objective-C++ or plain Objective-C ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  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