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

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 821 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 10 Sept 2020, 19:32 last edited by learnist 9 Nov 2020, 01:14
    #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
    • K Offline
      K Offline
      Kent-Dorfman
      wrote on 11 Sept 2020, 00:12 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 11 Sept 2020, 01:16
      0
      • K Kent-Dorfman
        11 Sept 2020, 00:12

        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 11 Sept 2020, 01:16 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 .

        J 1 Reply Last reply 11 Sept 2020, 07:10
        0
        • L learnist
          11 Sept 2020, 01:16

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

          J Offline
          J Offline
          JonB
          wrote on 11 Sept 2020, 07:10 last edited by JonB 9 Nov 2020, 07:11
          #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

          4/4

          11 Sept 2020, 07:10

          • Login

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