Unsolved How to detect the button press in GUI for optional mode in GUI
-
I am working with some headless / headmode application which can run in both mode in GUI mode and Non - GUI mode.
I have a button in my form. (I will create a instance of this form only when I need to launch my application in GUI mode)
I have one button class(core class) will detect my button press (through command using putty) which will have variable (bEnabled ).
I also want to enable the button in GUI when I run the application in GUI mode and when I try to press the button using command in core class.
Please note that I will create instance of GUI (where button is there) in GUI form.
When running in non-gui form i will only set the button class with (bEnabled)But in gui mode I also need to set that enabled in GUI also. How can I do that ?
Please note that logic is seperate for GUI and core.
-
@Ayush-Gupta I'm not sure I understand your description, but what about signals/slots?
-
typedef enum
{
btn_down,
btn_up
}buttonState;class ButtonClass
{
public:
ButtonClass();
void enableButton();
void disableButton();
void buttonPresssed();
void buttonRelease();private:
bool bReleased;
bool bEnabled;
buttonState eBtnPos;
};I have this button class while will declare a virtual button if I need to run application with non-gui mode
when I need to press the button I will call
ButtonClass test;
test->enabled();When GUI enabled I need to enable the Button in GUI also.
-
@Ayush-Gupta Sorry I don't understand...
What exactly is the problem/question? -
I have seperated my application in two parts (GUI and Core).
so that I can run my application in both mode GUI mode and Non-GUI mode.
I have one form which is having one button (which I will launch in GUI mode of application).
I have one button as I described above which is in my core part.
When I tried to do the button press in core part I want that same to be reflected in my GUI part.
But the reflection in GUI part should be optional.
-
Is your
ButtonClass
even aQPushButton
or what kind of class is this?So your problem is that you have your virtual button in non-GUI mode, which sets a variable when you trigger it and you dont know how to do this with a "real" pushbutton in GUI mode?!
-
@Pl45m4 My problem is if i press virtual button how It will enable in real button in GUI. (In Gui mode)
-
Use signals & slots, as @jsulm already said.
When you click your virtual button, send signal to GUI class and enable / show your GUI Pushbutton. -
@Pl45m4 But problem is here my core non-virtual button is seperated by GUI.
And I will not create instance of GUI for non-gui mode. -
@Ayush-Gupta said in How to detect the button press in GUI for optional mode in GUI:
And I will not create instance of GUI for non-gui mode.
So what? In this case you do not connect signals/slots...
-
@jsulm That seems to static compilation than ? Can you give some example?
-
@Ayush-Gupta What static compilation? What examples? How to connect a signal to a slot?
You know when you run with GUI and when without, right? If you run with GUI then connect signal/slot. -
I am not getting how can I have reference of core (non-virtual button) in GUI so that I can use signal/slot
-
how the slot/signal will help if I call virtual button enabled function ? In that I am only setting variable bEnabled ??
How can I map the core non- virtual button with real gui button?
-
Hi,
It seems you have a design issue here. From the looks of it you should rather implement some IPC for your console application which seems to act a bit like a daemon. With that then you can pilot it with your GUI or from somewhere else.