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
Forum Updated to NodeBB v4.3 + New Features

How to implement OCX functions

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.8k 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 7 Feb 2016, 08:14 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
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 7 Feb 2016, 09:02 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 7 Feb 2016, 11:42
      0
      • M mrjj
        7 Feb 2016, 09:02

        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 7 Feb 2016, 11:42 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
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 7 Feb 2016, 12:06 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 7 Feb 2016, 13:46 last edited by
            #5

            Not sure

            1 Reply Last reply
            0
            • B Offline
              B Offline
              borisa
              wrote on 7 Feb 2016, 14:30 last edited by
              #6

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

              How can i fix it?

              M 1 Reply Last reply 7 Feb 2016, 14:46
              0
              • B borisa
                7 Feb 2016, 14:30

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

                How can i fix it?

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 7 Feb 2016, 14:46 last edited by mrjj 2 Jul 2016, 14:48
                #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 7 Feb 2016, 23:04 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

                  1/8

                  7 Feb 2016, 08:14

                  • Login

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