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. Calling update frequently
Forum Updated to NodeBB v4.3 + New Features

Calling update frequently

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.7k Views 1 Watching
  • 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.
  • Z Offline
    Z Offline
    ZeeQ
    wrote on last edited by
    #1

    hi all,

    i am newbie to qt so please bear with me if solution is very obvious. My question is that i have a class MapGenerator which is calling a function of my Qt class Mainwindow and updates the value of a variable and later this variable is used in paintevent method. i.e
    @class MapGenerator{
    void somefunction()
    {Mainwindow w:
    w.updatemap(data):
    }
    }:@

    Now in class Mainwindow i have

    @class MainWindow{
    void updatemap(int data)
    save data;

    }
    void paintEvent(){
    using that data doing painting
    }
    };@

    Now the problem is that when first time updatemap is called and paint event gets that data and paint but for the second call or frequent call i dont know how to handle recalling paintevent . i tried update() in MainWindow::updateMap() after saving data but it yielded me segmentation fault.
    (p.s class MapGenerator is on other thread so updatemap is being called from other thread not the main thread so update() shouldnt work from there but signals/slot also gives the same error)

    i am using ubuntu 10.04 with qt 4. The code provided here is just psuedo code for keeping things simple.
    Thanks

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AcerExtensa
      wrote on last edited by
      #2

      How about timer which will check changing of value and signal update if value is changed.

      God is Real unless explicitly declared as Integer.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mkuettler
        wrote on last edited by
        #3

        Emitting a signal in updateMap that is connected to MainWindow::update() should work, even when the signal is emitted from a seperate thread. The slot should then be executed in the receiver's thread.

        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