Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT Problem -Can i make my ui pointer static ?, because i want to use it in a static function
QtWS25 Last Chance

QT Problem -Can i make my ui pointer static ?, because i want to use it in a static function

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++qt 5.4static methodstatic
4 Posts 3 Posters 816 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    learnist
    wrote on last edited by learnist
    #1

    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.

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      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.

      L 1 Reply Last reply
      0
      • Kent-DorfmanK Kent-Dorfman

        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.

        L Offline
        L Offline
        learnist
        wrote on last edited by
        #3

        @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 .

        JonBJ 1 Reply Last reply
        0
        • L learnist

          @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 .

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @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().

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved