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. [solved] directory tree and file list Beginners question
Forum Updated to NodeBB v4.3 + New Features

[solved] directory tree and file list Beginners question

Scheduled Pinned Locked Moved General and Desktop
24 Posts 2 Posters 12.8k 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.
  • A Offline
    A Offline
    AcerExtensa
    wrote on last edited by
    #11

    It's OK. Qt tutorials and videos will help you a lot too!

    God is Real unless explicitly declared as Integer.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SherifOmran
      wrote on last edited by
      #12

      I have another question, that i would appreciate if you help me with it.
      I am using MAC, it is possible from my MAC QT to produce an exe compiled version and / or linux or should I install QT over windows and linux?

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

        No you can't, you can maybe cross-compile for linux, but not for windows(you can cross-compile for linux and install complete cygwin system on your windows, it will work, maybe....).

        God is Real unless explicitly declared as Integer.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SherifOmran
          wrote on last edited by
          #14

          how do you use the setwindowmodality?
          I need the browse window to be child and can not be reopened unless before closed

          @
          Browse * w = new Browse(dB_Setting);
          w->show;
          @

          @ Browse class

          this->setWindowModality(Qt::WindowModal);
          @

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

            Set it in your Browse class constructor:
            @
            Browser::Browser(QWidget *parent):QWidget(parent)
            {
            qDebug() << "input filename " << input_filename;
            this->setWindowModality(Qt::ApplicationModal);
            @

            If you really want to block event loop of main application and stay in on_loginbrowse_clicked function till user closes browse widget, make your Browse class subclass QDialog instead of QWidget, QDialog has own event loop. So your code will work well:

            @
            class Browse : public QDialog
            {
            Q_OBJECT
            public:
            ...
            @

            @
            void Login::on_loginbrowse_clicked()
            {
            // selecting a new setting.dB file
            Browse w("Setting.dB"); // Browse searching for Setting.dB
            }@

            God is Real unless explicitly declared as Integer.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SherifOmran
              wrote on last edited by
              #16

              I changed to QDialog as follows

              @

              class Browse : public QDialog
              {
              Q_OBJECT

              public:
              explicit Browse(QString input_filename, QWidget *parent = 0);
              ~Browse();
              QString OutputFileName;

              @

              @

              QString InputFileName;

              Browse::Browse(QString input_filename, QWidget *parent) :
              QDialog(parent)
              {

              @

              Then i use the following to test waiting loop of QDialog

              @
              oid Login::on_loginbrowse_clicked()
              {
              Browse * w = new Browse(dB_Setting);
              w->show();
              qDebug() << "return from browse";
              }
              @

              but when i click on browse, it prints return . It should wait till i select a file and then I should return the file name selected. I am still struggeling with it.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SherifOmran
                wrote on last edited by
                #17

                OK I found it, it should be
                @
                w->exec();
                @

                and not
                @
                w->show();
                @

                but how to return the value selected?

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

                  I've told you, if you use QDialog you can use your code:

                  @
                  oid Login::on_loginbrowse_clicked()
                  {
                  Browse w(this,dB_Setting);
                  w.exec();
                  qDebug() << "return from browse";
                  }
                  @

                  God is Real unless explicitly declared as Integer.

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

                    Or so... :)

                    You need filename value, right? Create function for getting this value:
                    @
                    public:
                    QString getValue(){return this->filename;}

                    @

                    after dialog exits you can get your value like this:
                    @
                    void Login::on_loginbrowse_clicked()
                    {
                    Browse * w = new Browse(dB_Setting);
                    w->exec();
                    qDebug() << "return from browse: " << w->getValue();
                    //and don't forget to delete this instance:
                    delete w;
                    }
                    @

                    God is Real unless explicitly declared as Integer.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SherifOmran
                      wrote on last edited by
                      #20

                      I have an issue over MAC. I need to show drives or at least to start with the current apppath folder

                      I used the following filter but I don't see drives, I have / only however when i loads, it shows volumes folder and the dissapears. I can not set the current path of the modelview to the current directory called set in AppPath QString.

                      @
                      dirmodel->setFilter(QDir::Dirs | QDir::Drives | QDir::NoDotAndDotDot | QDir::AllDirs);
                      @

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SherifOmran
                        wrote on last edited by
                        #21

                        Solved showing drives in MAC, since folder volumes is hidden, I used QDir::Hidden.
                        Although this is not the proper way but it is a bug in QT "Reported here":https://bugreports.qt-project.org/browse/QTBUG-6875

                        @
                        dirmodel->setFilter(QDir::Dirs | QDir::Drives | QDir::Hidden | QDir::NoDotAndDotDot | QDir::AllDirs);
                        @

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SherifOmran
                          wrote on last edited by
                          #22

                          I have another question, I created a QDialog on the fly as this, then I want to differentiate between being closed normally with the (x) button or being closed through the ok button.

                          @
                          QDialog *modifypsswdwin = new QDialog (this);
                          QLabel *newpsd1 = new QLabel(this); newpsd1->setText("New password");
                          QPushButton *modifypsswdwin_ok = new QPushButton(this); modifypsswdwin_ok->setText("OK");
                          connect(modifypsswdwin_ok,SIGNAL(clicked()),modifypsswdwin,SLOT(close()));
                          int ret=modifypsswdwin.exec();
                          @

                          I searched and found that I need to do
                          @
                          QDialog.setResult(1)
                          @

                          but the question is how to setthe result if i have only 1 line in the connect. Is it possible to write multiple commands in the slot(close)?

                          thank you

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            SherifOmran
                            wrote on last edited by
                            #23

                            I found it, we should connect accept to the button as well

                            connect(modifypsswdwin_ok,SIGNAL(clicked()),modifypsswdwin,SLOT(accept()));
                            connect(modifypsswdwin_ok,SIGNAL(clicked()),modifypsswdwin,SLOT(close()));
                            
                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              SherifOmran
                              wrote on last edited by
                              #24

                              I have a problem with the stylesheet. I use a style sheet file. I want to set a style sheet for this browse class from the file and not hardcoded. It works when it is hardcorded in the program but i don't know how to call it in the file. I tried #Browse and tried QDialogBox#Browse but did not work.

                              Any idea?

                              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