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. Import string from another window (newDialog.ui) to MainWindow?
Forum Updated to NodeBB v4.3 + New Features

Import string from another window (newDialog.ui) to MainWindow?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 5 Posters 2.0k 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.
  • I Offline
    I Offline
    itsmemax
    wrote on last edited by
    #1

    Hi, I've made a settings window (a new GUI class). When I click on a button named "Settings" in my MainWindow, the settings window opens. Everything ok. But in this settings window you can choose a working directory from a QFileDialog.. The returned QString should be imported into my MainWindow class.. A little pictorialization:
    !http://i.imgur.com/KIdomAV.png(picture)!

    How can I solve this? I thought of QSettings, but I never used this before and the example in the doc is complicated.

    1 Reply Last reply
    0
    • I Offline
      I Offline
      itsmemax
      wrote on last edited by
      #2

      No one can help? It's urgent..

      1 Reply Last reply
      0
      • G Offline
        G Offline
        GrahamL
        wrote on last edited by
        #3

        Hi
        You could provide a method in NewDialog to return the string

        1 Reply Last reply
        0
        • francescmmF Offline
          francescmmF Offline
          francescmm
          wrote on last edited by
          #4

          You also can emit a signal with a string and connect inside your MainWindow class.

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hardcodes.de
            wrote on last edited by
            #5

            Since settings are often needed from all classed across the program, you could store the information in a "global" class, e.g. named properties and make them available via static.

            while(!sleep){++sheep;}

            1 Reply Last reply
            0
            • G Offline
              G Offline
              gvedantam
              wrote on last edited by
              #6

              What I understand from your requirement is that your settings window is child of your Mainwindow.
              So, you should have definitely passed MainWindow as parent in your Settings window constructor.
              If that is the case, then you can write a public member fucntion say SetFileName() and you can call it in your settings windows after returning from QFileDialog::getExistingDirectory().

              Its something like this

              if (!dir.isEmpty()
              {
              parent->setFileName(dir)
              }

              Passing parent widget to the child's constructor is the proper way to do it. Even though you didn't do it you can use QWidget::parentWidget() to get its immediate parent. But you should make sure that it exists.

              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