How to Save Color with QColordialog in Qt C++ - savechanges

Can someone help with this problem,I am using the QColorDialog in QT c++ ad can't figure out how to save the selected color so it would be the same color after an app is shutdown and then restarted. I have included my slot here if it would help, the app work fine as long as you shut it off and restart it.
void MainWindow::on_actionBackGround_Color_triggered()
{
QColor color=QColorDialog::getColor(color);
if (color.isValid()) {
setPalette(QPalette(color));
{
{
Thanks for and help,it's been awhile.

Related

JavaFX Native Bundle Splash Screen

I'm using the javafx-maven-plugin and IntelliJ IDEA on Windows 7.
I'm trying to get a splash screen to show while my JavaFX application boots up, like this:
I tried using the SplashScreen-Image manifest entry—and that works, but only if you click on the .jar—I'm deploying the application as a Native Bundle and so the user clicks an .exe (or a shortcut to an .exe) not the actual .jar.
When you click the .exe no splash screen is shown.
This SSCCE I made will help you help me.
If I'm deploying my app using the javafx-maven-plugin, (which, if I'm not mistaken, uses the JavaFX Packager Tool, which uses Inno Setup), how can I get a splash screen to show after the user clicks the .exe?
More Findings:
Looking at the installation directory, I find a .dll called runtime\bin\splashscreen.dll. Does that mean it can be done?
The native launcher does not respect that spash-screen, it is only when being invoked by the java-executable. As the native launcher is loading the JVM internally, this won't work.
I haven't found a proper way to get this working, not even with some preloaders. Maybe you can find this helpful: https://gist.github.com/FibreFoX/294012b16fa10519674b (please ignore the deltaspike-related stuff)
Copied code:
#Override
public void start(Stage primaryStage) throws Exception {
// due to the nature of preloader being ignored within native-package, show it here
SplashScreen splashScreen = new SplashScreen();
splashScreen.show(new Stage(StageStyle.TRANSPARENT));
// needed for callback
final SomeJavaFXClassWithCDI launcherThread = this;
// for splashscreen to be shown, its needed to delay everything else as parallel task/thread (it would block otherwise)
Task cdiTask = new Task<Void>() {
#Override
protected Void call() throws Exception {
// boot CDI after javaFX-splash (this will "halt" the application due to the work done by CDI-provider
bootCDI(launcherThread);
// push javaFX-work to javaFX-thread
Platform.runLater(() -> {
primaryStage.setTitle("Some Title");
// TODO prepare your stage here !
// smooth fade-out of slashscreen
splashScreen.fadeOut((ActionEvent event) -> {
primaryStage.show();
splashScreen.hide();
});
});
return null;
}
};
// run task
new Thread(cdiTask).start();
}
In short: I'm creating my splashscreen myself.
Disclaimer: I'm the maintainer of the javafx-maven-plugin

xamarin application not quitting right

I noticed something strange with my Xamarin application.
First in Xamarin: Running the Application was fine until I click the upper right X to close the App. In Xamarin the button on the left is still a red square and I can "stop the current startup project".
Second: after packing up the application (7zip) and starting it out of the archive, after closing the app, 7zip told me to stop the application before it is able to close the archive.
Is there anything i'm missing here? Do i have to setup anything to shutdown the App properly?
there even is a OnDeleteEvent
protected void OnDeleteEvent(object sender, DeleteEventArgs a)
{
Application.Quit();
a.RetVal = true;
}
but with a breakpoint there, it seems not to be used when clicking the X-Button.
Note: I'm using the GTK#2.0 Project template with Xamarin 6.2
i had to add the line
this.DeleteEvent += new global::Gtk.DeleteEventHandler(this.OnDeleteEvent);
into the sourcecode of my MainWindow. Somehow this line was missing.
It's working as intended now.

Detect Application Quit with Unity?

I'm trying to use System.AppDomain.CurentDomain.ApplicationExit += new System.EventHandler(SomeFunction); to call the function SomeFunction when the application closes. In this case Unity 3D. But it doesn't work. I have no idea why. It is an editor script and is not an instance (static). What do you think I'm doing wrong?
There is no OnApplicationQuit method for Windows. According to the official documentation:
On Windows Store Apps and Windows Phone 8.1 there is no application quit event. Consider using OnApplicationFocus event when focusStatus equals false.
Therefore, instead of checking whether or not the application closed, you'll want to check whether or not the application obtained or lost focus.
In C#:
void OnApplicationFocus(bool focus)
{
if (!focus)
{
//Do something
}
}
The documentation does not explicitly mention it, but it can be assumed OnApplicationQuit is intended for Android only as iOS also does not support it.
You could use
function OnApplicationQuit() {
//put script in here
}
So that before the application quits it calls that function and does what ever is in the { and }

WPF Application crashes on WIndows 7 when command executable.Start() is run

I've got a tiny Portal I´m writing, and this portal is supposed to launch installers on button click. I´m developing on VS2010 on a WinXP SP3 station, and on this machine, even fter compilation and publishing, everything works as expected. However, when i run the compiled application in Windows 7, it crashes...The application work, it just crashes when i click a button for program installation.
The programming looks like this:
private void button_access_Click(object sender, RoutedEventArgs e)
{
Process executable = new Process();
string executablePath = "D:\\Visual Studio 2010\\SAFE_Portal1\\SAFE_Portal1\\Extra Programs\\AccessRT2003.exe";
executable.StartInfo.FileName = executablePath;
executable.Start();
}
It specifically crashes on thr button_access_Click procedure...
Any ideas as to why this could be? I`ve tried looking around here in Stackoverflow, and in other forums, but to no avail...
Any help or direction is ganz welcome!
Try this:
try
{
Process executable = new Process();
string executablePath = "D:\\Visual Studio 2010\\SAFE_Portal1\\SAFE_Portal1\\Extra Programs\\AccessRT2003.exe";
executable.StartInfo.FileName = executablePath;
executable.Start();
}
catch (Exception msg)
{
MessageBox.Show(msg.Message);
}
What message are you getting?
Are you sure you want to use fixed paths in your application? If so you should at least check if the file you try to start exists beforehand. Otherwise an exception will be thrown which could be the problem here.
if (File.Exists(executablePath))
{
...
}

Problems with using TrackPopupMenu on win7

I'm trying to create context menu using TrackPopupMenu function in my application, the code I use in it is like the following:
CMenu menu;
if (menu.LoadMenu(IDR_MENU_TRAY))
{
CMenu* pSubMenu = menu.GetSubMenu(0);
if (pSubMenu != NULL)
{
pSubMenu->ModifyMenu(IDM_CLOSE,MF_BYCOMMAND,IDM_CLOSE ,g_cfg->GetLang(TEXT_MAIN_CLOSE,"Exit(&X)"));
pSubMenu->ModifyMenu(IDM_SHOW,MF_BYCOMMAND,IDM_SHOW ,g_cfg->GetLang(TEXT_MAIN_OPEN_SHUTTER,"Open(&O)"));
CPoint point;
GetCursorPos(&point);
SetForegroundWindow();
pSubMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON, point.x, point.y, messageOnlyWnd);
}
}
The code runs perfect on WinXP, while on win7 and vista it doesn't. The Problem on win7 and vista is that it takes a fairly long time to pop up the menu, maybe 1 min or more. But if I turn off the Aero on win7 or vista, it runs smoothly just like on winXP, so I guess somethin must be conflicted with Aero in the code, but I just don't know how to fix it. Is there anyone can help me with that? I will appreciate it a lot if anybody helps me out.
I don't see anything wrong with this code. I've used TrackPopupMenu on Vista without any problems. The source of the problem might lie elsewhere. Try removing the call to SetForegroundWindow. If that doesn't work, try creating an empty project with just the popup menu code.

Resources