Qpushbutton mouse click not working with GUI
I have Widnows Vista installed on my system and recently installed QT 4.5.2 ON my system
I am totally a newbie and was running some examples when i found out that whenever I run apps with QpushButton added using Qdeveloper by dragging and ddropping
it doesnt work
I add slot to it but on running app, clicking on the Push button doesnt work, though pressing the enter button does the job but no Mouse press works. Pls help and telll where i am lagging
The examples that i used which involved declaring and then connecting via connect worked fine but where am i going wrong graphically
please help
thanks in advance
Re: Qpushbutton mouse click not working with GUI
You really need to show some code for this problem. Better yet, a short simple program that demonstrates the problem.
Gary
Re: Qpushbutton mouse click not working with GUI
i just used qtcreator
dragged and dropped a qpush button
then pressed f4 entered signal slot editor
there i connected pushbutton clicked() [not clicked(bool)]with Dialog's accept()
thats the reason when i press enter the dialog closes but that doesnt explain why mouse click on push button does not work ?
i didnt do any coding,
Re: Qpushbutton mouse click not working with GUI
Quote:
when i press enter the dialog closes but that doesnt explain why mouse click on push button does not work ?
because QPushButton have the current focus which will have both keyPressEvent() and mouseClickEvent() ... when u press enter it call signal clicked() of QPushButton ..
u have to reject() the keyPressEvent() on QPushButton or change the focus from QPushButton .. it will work ..
Re: Qpushbutton mouse click not working with GUI
Quote:
Originally Posted by
wagmare
because QPushButton have the current focus which will have both keyPressEvent() and mouseClickEvent() ... when u press enter it call signal clicked() of QPushButton ..
u have to reject() the keyPressEvent() on QPushButton or change the focus from QPushButton .. it will work ..
thanks wagmare, that explains a little but i found the real problem
It was layout
I just placed the buttons
and then on top of that i placed the layoit due to which the buttons being below it(the layout overlapping the button)
it never get clicked
Second when i add buttons over the layout the problems come that they take whole of the layout
so can anyone explicitly guiide me how to use layouts cause thats the main reason for me going wrong
When i added buttons on the layout, it worked perfectly fine
Hope to hear from you and sure to join your community
Re: Qpushbutton mouse click not working with GUI
In your main.cpp have something like this:
Code:
{
//make layouts and buttons
//connect button and function
connect(myButton, SIGNAL(clicked()), this, SLOT(myFunction()));
//set layouts and buttons
mainLayout->addLayout(buttonLayout);
buttonLayout->addWidget(myButton);
setLayout(mainLayout);
}
Then you would call this from your main function:
Code:
int main(int argc, char *argv[])
{
MyWidget window;
window.show();
return application.exec();
}
Of course your *.h file will need to declare the buttons and layouts accordingly. Like this:
Code:
{
Q_OBJECT
public:
public slots:
void myFunction(void);
private:
}
Hope that helped a bit.
Re: Qpushbutton mouse click not working with GUI
Am glad there's a forum like this...uhmmm am trying to build a GUI application with QT designer and i have various form( main windows & dialog) but my major problem is connecting objects in a form to object in another form...for instance clicking a pushbutton on the main wondow and have it open a dialog.......can i develop a gui, totally using Qt designer without writing codes?
Re: Qpushbutton mouse click not working with GUI
You can develop the GUI without coding, but you can't develop the functionality without writing code.