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. Communication of Application Preferences with Main Window...
Forum Updated to NodeBB v4.3 + New Features

Communication of Application Preferences with Main Window...

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 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.
  • H Offline
    H Offline
    Hephaestus
    wrote on last edited by
    #1

    I have a Main Window where I use a GLWidget as the central widget. I have created a Preferences dialog, similar to that of Qt and I would like to change the status of the GLWidget e.g. Enable/Disable Lighting by using a checkbox. I have tried to work with signals but didn't succeed. Any help would be really appreciated.

    Imagine my structure like this:

    -mainwindow.h
    -glwidget.h
    -settingsdialog.h
    -main.cpp
    -mainwindow.cpp
    -glwidget.cpp
    -settingsdialog.cpp
    -mainwindow.ui
    -settingsdialog.ui

    I construct the settings dialog the first time through the MainWindow. How do I have access of that specific checkbox,
    inside the glwidget.cpp? Is there any similar example/tutorial in qt demos?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      pmseattle
      wrote on last edited by
      #2
      1. How do you get to your settings dialog ? It sounds like you create it from within the constructor for MainWindow, from what you have written.

      2. Does the settings dialog have an OK/Cancel button box ? I would use the signal from pushing ( or releasing ) the OK button with a slot which would then retreive the state of the checkbox. Although you can also use signals associated with the checkbox itself if you prefer.

      3. Are you using forms in Qt Creator, or are you coding the main window and settings dialog by hand ?

      4. What exactly do you mean by "tried to work with signals but didn't succeed" ? You won't get far with your project without being able to use signals/slots.

      5. Could you post your code if it isn't too huge ?

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hephaestus
        wrote on last edited by
        #3

        First of all thank you very much for your time and response! I am not able to send you the full code at this moment. Maybe I can prepare a smaller example when I have some time. Here are the answers to your points:

        1. Yes, the Settings dialog is created inside the MainWindow.cpp. I have added a bool variable, so that it is not created from scratch every time.

        2. I have created the Settings dialog as a QWidget. Should I have used the QDialog instead? In my case I have created the OK/Cancel buttons, but I haven't assigned any signals yet, except from closing the settings window. Here I have one question: What is the prefered method? To assign all settings (e.g. 100 checkboxes) as signals to the OK button, or, get the status of each checkbox whenever it is needed?

        3. I have used Qt Creator to design both the Main Window and the Settings dialog, however I am familiar with coding also e.g. connect(...).

        4. I have tried to make simple examples with signals/slots which worked ok, because they were in the same .cpp file. This is the first time I am trying to connect two different .cpp files so I am a bit confused.

        5. As I said above, I may prepare a small example. However, what I need is not so difficult to solve even now, as I imagine. For example, let's assume a MainWindow which has a menu option e.g. File > Preferences. This option creates the Settings window the first time or just shows the already created. Inside settings I have a checkbox e.g. LightCheckbox. Then I would like to check inside my GLWidget.cpp if LightCheckbox is checked or not. Imagine this is something similar to QT Creator Preferences dialog.

        What do you think? Thanx again!

        1 Reply Last reply
        0
        • P Offline
          P Offline
          pmseattle
          wrote on last edited by
          #4

          I would have a preferences dialog as File>Preferences or Edit>Preferences. I would have a slot for the accepted signal from the OK/Cancel button box, which processes the results from whatever widgets were in the dialog.

          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