QT QSystemTrayIcon on mac is squashed in the second screen - macos

I create a system tray icon on MacBook. And I connect a screen with Mac. When I run this program,the system tran icon on the monitor is squashed.
QSystemTrayIcon *m_tTrayIcon = new QSystemTrayIcon(this);
m_tTrayIcon->setIcon(QIcon(QPixmap("/Users/xxx/Downloads/pic.png")));
m_tTrayIcon->show();
when the monitor is not focused, the icon is squashed.
and when I click the desktop of the monitor, the monitor is focused, the icon is also become normal.

This is a known bug in Qt with new verisons of MacOS. Check out this bugreport.
Solution would be either use fixed versions (they claim to fix it in 5.12.11 and 6.1.0) or compile cocoa plugin by your own and ship it with your application instead of one provided by Qt.
Fix is just a one line of code that you need to apply. The easiest way is:
download qtbase (for example from github) and checkout version you need
In case you will use Qt < 6.0.0 (i.e. building with qmake rather than with CMake) - copy .qmake.conf from root to qtbase/src/plugins/platforms/
you go to qtbase/src/plugins/platforms/cocoa and open cocoa.pro or CMakeLists.txt (depends on what version of Qt you have checked out)
you apply patch and compile the plugin
From now on you should use cocoa plugin you have just compiled instead of one shipped with Qt (either replace it in Qt installation or every time you deploy your application)

Related

WSLg QtCreator broken menus and no autocompletion

I'm using WSlg with Ubuntu 18.04 on windows 11 and I've installed on it the Qt Creator IDE. Via the WSLg I can easily launch it through the start menu of windows 11.
The issue is that while coding with it I have no autocompletion (ctrl + space shows no menu). Also the right click menu after a while goes nuts and start showing in weird places of the screen until it disappears completely; same for the menus on the top bar.
I attach a picture where I show how the right click menu shows up out of the boundaries.
Anyone encountered this issue and has a solution?
So for now I have found a workaround even if it's not a proper solution.
I was using QtCreator installed via the online installer that Qt Provides. I tried using the version that comes with apt-get and I do not have those issues. Also the windowing is different because is showing the usual gray boxing of the WSLg apps; so might be related to the XWayland server architecture or something similar.
Cons of this are that the QtCreator version that comes this way is not up to date with the latest and will rely on the qt libs you have installed on your wsl (being ubuntu 18 will be qt5 and not qt6, meaning you'll not have QtCreator 8).
Also right not I'm having issue on the ClangCodeModel but I think it's a different issue.

Deploy a Swift OS X app locally?

I am not new to programming, but I am new to Swift. I have developed a small app that I have no intention of distributing, I just want to use it for myself. Everything works just as desired in XCode and now I want to deploy that app locally. How can I run my app on my machine without needing to have XCode also running? I just want to see my app in my Applications folder and run it when I want. Does XCode put build files somewhere that I can access them and use outside of XCode?
On the Product menu there is an Archive option. Select that to create an archive of your app.
Xcode should then automatically open the Organiser window with the archive of your app selected.
You'll see a big blue button called Upload to App Store on the right with two smaller buttons below it. The one you want is called Export... Press it and you'll get a pane giving you various export options with different kinds of signing.
The bottom option creates an unsigned .app file which you can put in your Applications directory.
NB As Eric D says, you can just drag the app out of the products directory, but unless you edit the scheme, that will give you a debug build with less optimisation and with asserts activated.
Update for Xcode 11.2
As Bell B. Cooper points out, the process has changed slightly. Now when you archive an app, you get a window listing the apps and a big blue "Distribute" button. Pressing this, gets you a dialog box giving you the various options. Which one you choose depends on what you want to do with the executable. With Catalina, unless it's just for your own use, you probably want to go for one of the options that involves signing the app.
Edit: while this answer still works, it targets old Xcode versions and uses the debug version of your executable. For recent Xcode versions, and for using the release version of your executable, see JeremyP's answer.
Each time you build an OS X application with the current scheme, Xcode automatically populates the "Products" folder with the related app bundle.
You can find this folder in the Project Navigator:
Xcode > Project Navigator > "Products" folder
Your .app is in there and ready to be used and/or copied to the /Applications folder.

Unable to build using Xcode 4 - The selected run destination is not valid for this action

So I'm horribly confused by this error, other threads on Stack Overflow mention I should set the SDK, but I see no option to do this. I'm trying to build:http://wafflesoftware.net/shortcut/
And I get no options, and I can only choose My Mac 64-bit, and I want it in 32-bit. Really beginning to hate Xcode 4.
Here is the screenshot when I try to edit my scheme: http://groovyape.com/scheme.png
Thoughts?
Firstly, I have observed that when Xcode 4 decides my Mac is 64 bit and all my other schemes have vanished, a restart of Xcode fixes that.
If you still have the issue after a restart, go to Manage Schemes... (under the Product Menu) and click on Autocreate Schemes now button. Try to delete the other schemes and see if you can run the project now.
However, if the issue is that you need to set the SDK, that's different:
Click on the top-level project icon in the left hand panel
In the right hand panel that appears, select Build Settings (near the top).
Select "All" option (instead of Combined)
Ensure Base SDK is set appropriately, like "OS X 10.7".
FWIW I'm seriously considering reverting to Xcode 3.2.5 at the moment, 4 seems horrendously buggy.
In xCode 4.4.1, use Validate Settings to solve the problem!
I can select either 32bit or 64bit now.
Ran into the same error message ("The selected run destination is not valid for this action") when attempting to use XCode 4 to build/run a tiny Objective-C "Hello, World" project I created in XCode 3.x. Fixed it by choosing to "Manage Schemes..." from the drop-down menu to the right of the Stop button, deleting the one scheme on the list (click checkbox beside the scheme, then click the "-" button at the bottom left), and then clicking "Autocreate Schemes Now".
I also needed to change the "Base SDK" from 10.5 to 10.6, by clicking on 'folder' icon (beneath the Run button), clicking the root/top of the tree view below it, clicking on the blue icon below "PROJECT" in the pane just to the right, and then finally, choosing "Latest Mac OS X (Mac OS X 10.6)" to the right of that.
I had this issue today. I found switching Base SDK from Latest iOS (4.3) to iOS 4.3 fixed everything.
This will happen if XCode believes your mac is a 64-bit machine, when really it's a 32-bit. If this is the case for you, simply click on your project icon from the far-left pane - it's the menu item that displays your project name next to a little blue icon. This should bring up a center pane that says "PROJECT" at the top. Highlight your project name, and the third pane should now show your build settings. The first item is "Architectures" which will allow you to specify if you are building a 32-bit or 64-bit application.
Kind of amazing that none of the answers here solved the issue for me, but I figured it out. Forget restarting Xcode, or using Autocreate Schemes, still only 64-bit will show up as a valid destination in the scheme.
The correct solution is to change the Architecture for your project. Go to Build Settings (in the root node of your project), and change Architecture to 32-bit Intel, it's right above the Base SDK setting. Destination will instantly switch to "My Mac 32-bit". HTH somebody.
It sounds as if you're trying to run (Cmd-R or run button) the framework (which you can't do - it's not an executable, just a library) rather than simply build it (Cmd-B).
I had this issue and maybe it was a coincidence but when I restarted XC4 but this time didn't choose to load my project from the popup window that appears on launch - instead choosing it explicitly from the File menu - the issue didn't occur and the build started ok.
On the 3 or 4 occasions I had this error, I had chosen to load the project from the popup window that appears when XC4 first loads.
As I say, I might have just got lucky, but I certainly didn't make any other changes to the projects to 'fix' the issue.
I found a good practice for moving from Xcode 3.2.X to Xcode 4 is, to remove any references to older SDKs (in the case of Mac OS to remove any Base SDK Ref, etc., for Mac OS <= 10.5, in the case of iOS I think you need to remove everything <= 4.3) PRIOR to upgrading to Xcode 4.
I never experienced any problems for new Projects, created in Xcode 4, only for such that where created with Xcode 3.X or 2.X
Xcode 4.5. I was trying to compile for 10.6. It seemed to be stuck on 64 bit just because it couldn't find the sdk. I didn't get any message about it not finding the sdk.
I first tried to put in the correct path to /Developer-3.2.6/SDKs/MacOSX10.6.sdk but xcode didn't want to find it there. Then I copied that folder into 4.5 next to the other OSX Platform sdk (new location I think just look in the bundle).
And magically my 32 bit came back.
So my conclusion is that the 32/64 bit option is really dependent on whether xcode can verify the sdk that you're trying to use. Being stuck at 64 while trying to compile for 32 gives the error without notifying you that its first issue is that the sdk can't be found.
I fixed this by deleting my xcuserdata in my Project file. Not sure how it got corrupt. But it worked for everyone else in the office, deleting the xcuserdata did the trick. I made sure Xcode was closed while doing so. Just for fun, make sure you delete your DerivedData folder for the app, and do a build clean for superstitious folks.
If this happened after you renamed your app, go to Schemes -> Edit Scheme -> Run <YourApp> -> Info
Select the right executable file (YourApp.app)
Another way is to select None as executable and then reselect the YourApp.app from your Debug-iPhoneOS folder.

How to go fullscreen in Xcode?

Is there a way to go fullscreen in Xcode? similarly to VS.net ?
and if there is, how?
FWIW, the modern answer to this old question has two parts:
1) Use View->Fullscreen to go full screen
and ... so you don't end up with one fullscreen window per file (which would be ridiculous) ...
2a) Use Shift-Option-click to open new files in the same window
2b) Use Navigation Preferences to specify that files always open in a new tab
With Xcode 4.1, a build-in full screen mode in included.
It works pretty well if you don't use multiple monitors.
You could use the SIMBL plugin Megazoomer for that. That's a plugin that will add a zoom menu item to every Cocoa application which will show the app's content in full screen.
Slight problem though, it doesn't work with Xcode out of the box. Building the old version for 32Bit with GC enabled works when running Xcode 3.2.4 in 32-Bit mode. But unfortunately, Ian did not release the sources for the 64Bit version. So if you really really want it, ask him for the sources and build a version that runs in 64Bit Xcode.
I believe the newest version of Xcode is in an application window, so that would be able to 'go fullscreen'. Are you using the newest version of XCcde? http://developer.apple.com/technologies/tools/whats-new.html
it doesn't seem there's a decent one
Edit:
This was for XCode 3 and earlier, XCode 4 and later came in one window.
Please refer to other answers

How do I change what version of GCC Xcode uses?

Currently, I am trying to compile Imprudence, a third party viewer for the Linden-Lab owned Second Life. I have gotten everything set up and I am now in Xcode. When I click on the Build And Run button, I get an error after a little bit stating that GCC 4.2 is not compatible with the Mac OS X 10.4 SDK.
I have tried changing the Active Architecture in Xcode to x86_64, i386, and ppc. None of these options have changed anything. I am running Mac OS X 10.6.4 and Xcode version 3.2.3. Can anyone tell me why this might be happening? Thank you!
See: http://developer.apple.com/tools/xcode/xcodebuildsettings.html
Basically, you need to go to the "Build" tab on the info window, and change the compiler version.
Edit: Seems like your problem is the SDK you're linking against not the compiler version. Fortunately, you can change the SDK version from the same panel I talked about.
You can change the compiler setting in the "Build" pane in the project's info panel. You can set both the targeted version and the compiler. These settings will cascade to each target, or can be overridden on a target-by-target basis using the same pane in the target's info panel. The base SDK for the project is set in a popup on the "General" pane of the project's info panel.

Resources