Results 1 to 6 of 6

Thread: QCheckBox trouble + How to refresh a paint window if an other is open over and select

  1. #1
    Join Date
    Mar 2018
    Posts
    33
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Windows

    Default QCheckBox trouble + How to refresh a paint window if an other is open over and select

    My goal is to freeze the state of checkbox when i push the START button and unfreeze it when i push the STOP button, i write this code but it doesn't work (find the line "//SUGGEST WHAT TO DO" and make a brekpoint at about line 186); see the file.
    An other question is:
    I write an other program that visualize the data that i've sended (with Qpaint->repaint() call), but if this window isn't select the paint window isn't refresh till i select it; what is the best practice to do it? My goal is to refresh the window even it isn't select.
    An other question is:
    What is the best practice to open an other window and pass to the new window all parameters/class of mainwindow?
    Thank you.
    Attached Files Attached Files

  2. #2
    Join Date
    Mar 2018
    Posts
    33
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QCheckBox trouble + How to refresh a paint window if an other is open over and se

    I found this solution for paint the widget if even the window is not selected:
    you have to set this attribute in the mainwindow where the widget are inserted (but i have a trouble when i paint the last draw i want):
    setAttribute(Qt::WA_ShowWithoutActivating);

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QCheckBox trouble + How to refresh a paint window if an other is open over and se

    If you want to "freeze" a widget, simply set it to "disabled".

    Not sure what you mean with not painting while not being selected.

    When a widget has new data to display, it can simply request redrawing by calling its update() method.
    Qt will then issue a new paint event and let the widget redraw itself.

    If you need to share data between windows, simply pass a pointer or reference to that data, for example as an argument to the second window's constructor.

    Cheers,
    _

  4. The following user says thank you to anda_skoa for this useful post:

    andreaQt (20th May 2019)

  5. #4
    Join Date
    Mar 2018
    Posts
    33
    Thanks
    18
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QCheckBox trouble + How to refresh a paint window if an other is open over and se

    .. so i have just to #include "mainwindow.h" in the file nextwindow.h ..
    ok, thank you anda_skoa.
    where i can find the button to close this thread/post?

  6. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QCheckBox trouble + How to refresh a paint window if an other is open over and se

    Quote Originally Posted by andreaQt View Post
    .. so i have just to #include "mainwindow.h" in the file nextwindow.h ..
    Only if the new window needs to access the previous window's API.

    Quote Originally Posted by andreaQt View Post
    where i can find the button to close this thread/post?
    That's not necessary.

    Cheers,
    _

  7. The following user says thank you to anda_skoa for this useful post:

    andreaQt (27th May 2019)

  8. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QCheckBox trouble + How to refresh a paint window if an other is open over and se

    .. so i have just to #include "mainwindow.h" in the file nextwindow.h ..
    Usually that's a sign of a "very bad idea", especially if it means you would be doing something like declaring MainWindow's "ui" or other member variables as public so that NextWindow could have access to it.

    Think about how to accomplish the same thing in the Qt way - use signals and slots to set up a member function level communication between MainWindow and NextWindow. If something changes in MainWindow that NextWindow needs to know about, create a signal for that in MainWindow and a slot to handle it in NextWindow. Connect those in the part of MainWindow where NextWindow is created. If you do it correctly, there will be no need at all to include the mainwindow.h header in NextWindow's code.

    You will have to include nextwindow.h in MainWindow's code, but you have to do that anyway if you are going to create an instance of NextWindow from inside of MainWindow's code. But there is usually no need at all to go the other way.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  9. The following user says thank you to d_stranz for this useful post:

    andreaQt (27th May 2019)

Similar Threads

  1. Refresh my Qt window
    By maarvi in forum Newbie
    Replies: 6
    Last Post: 8th May 2011, 20:31
  2. window refresh freeze
    By jhowland in forum Qt Programming
    Replies: 1
    Last Post: 22nd February 2010, 08:58
  3. Replies: 1
    Last Post: 23rd October 2009, 23:48
  4. QPainter and refresh window
    By Atikae in forum Qt Programming
    Replies: 3
    Last Post: 18th February 2009, 13:45
  5. Want to refresh window without processEvents()
    By jnk5y in forum Qt Programming
    Replies: 6
    Last Post: 31st March 2006, 01:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.