QT Problem -Can i make my ui pointer static ?, because i want to use it in a static function
-
i am using Windows API function(mouseProc) to get some value in QString named result_string inside my function
LRESULT CALLBACK MainWindow::mouseProc(int Code, WPARAM wParam, LPARAM lParam) { //Do something to generate value of QString result_string; // now i want to print this result_string in my textbox using ui->textbox->append(result_string); //note: i am able to print result_string in the console using qDebug() << result_string; //but now i cannot print result_string in textbox, since this MouseProc funtion is declared as a static function. in my .h (static LRESULT CALLBACK mouseProc(int Code, WPARAM wParam, LPARAM lParam); ) }
How can i print QString result_string in my Qtextbox ? The mouseproc function has to be a static callback function in this scenario.
-
you shouldn't be using the windoze mouse callback and expecting to call Qt functions from it. You should be using the Qt mouse events if you want to access Qt functions.
-
@Kent-Dorfman i tried Qt mouse events , but they dont work for my use case , because i need to intercept clicks even inside and outside of my mainWindow.
is there a way i can make my ui pointer static ? i am facing syntax errors in this .
-
@learnist
No, you can't change over something to do with instances to become static.You might create some static/global pointer for yourself and set it to point to a particular instance of a window or a widget or your textbox or something. Or, you might "walk" your windows to find what you are looking for, starting from, say,
static QWidgetList QApplication::topLevelWidgets()
.