Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7666329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:48:22+00:00 2026-05-31T14:48:22+00:00

I would like to know if there is a way to use the Cocoa

  • 0

I would like to know if there is a way to use the Cocoa API in a Qt application.

I’ve already used the Windows API to get the selected text from the active application.
I’d like to do the same with mac os.
I tried to make a simple “hello world” application C++ with xCode, including the <Cocoa/Cocoa.h> but it didn’t work as I excepted.
Is there a way to get this “hello word” application to build with Cocoa?

And, also If that is possible, can I get the selected text from the active windows with Cocoa API?

EDIT :

All right, so I successfully build something using Cocoa.h, thanks to this thread : How to mix Qt, C++ and Obj-C/Cocoa.

For the selection problem you could check out the answers I posted which tell you how to do it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:48:23+00:00Added an answer on May 31, 2026 at 2:48 pm

    For those who could be interested : I found a way to get the current selected text.

    Just by simulating cmd + c :

    So thanks to this thread, I changed the code to obtain the “c” key which is represented by the integer 8 (Found in NSEvent.h), so here’s the code :

    CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateCombinedSessionState);
    CGEventRef saveCommandDown = CGEventCreateKeyboardEvent(source, (CGKeyCode)8, YES);
    CGEventSetFlags(saveCommandDown, kCGEventFlagMaskCommand);
    CGEventRef saveCommandUp = CGEventCreateKeyboardEvent(source, (CGKeyCode)8, NO);
    
    CGEventPost(kCGAnnotatedSessionEventTap, saveCommandDown);
    CGEventPost(kCGAnnotatedSessionEventTap, saveCommandUp);
    
    CFRelease(saveCommandUp);
    CFRelease(saveCommandDown);
    CFRelease(source);
    

    Now you just have to access the clipboard from Qt to get the selection. (If ask, I can put the code to do so)

    Anyway, thanks to the stackoverflow community 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know if there is a way to use an order
I would like to know if there is a way that i can get
I would like to know if there is any way to use a key
I would like to know if there is any way to use wildcards when
I would like to know if there is a way to use i18n with
I would like to know if there is a way in B4A to get
I'm new to PowerBuilder 12, and would like to know is there any way
I would like to know if there's a way in java to find out
I would like to know if there is a way to execute polygons queries
I would like to know if there is any way to find the actual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.