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. Active window
Forum Updated to NodeBB v4.3 + New Features

Active window

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 2 Posters 3.5k 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.
  • T Offline
    T Offline
    TETTRA
    wrote on last edited by
    #1

    The window is open, but the button that called it does not work. Until the window disappears.

    mrjjM 1 Reply Last reply
    0
    • T TETTRA

      The window is open, but the button that called it does not work. Until the window disappears.

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @TETTRA
      can you please show the code ?

      T 1 Reply Last reply
      1
      • mrjjM mrjj

        @TETTRA
        can you please show the code ?

        T Offline
        T Offline
        TETTRA
        wrote on last edited by
        #3

        @mrjj Call:

               //new
                newFile = new QAction (tr("New"),this);
                  newFile->setShortcut(QKeySequence::New);
                  connect(newFile,&QAction::triggered,this, &MainWindow::newfile);
                  file->addAction(newFile);
        

        slot:

        void MainWindow::newfile(){
            newF *newf = new newF();
            newf->show();
        }
        
        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          looks fine

          So MainWindow::newfile is called ?

          but newF is not shown or ?

          T 1 Reply Last reply
          1
          • mrjjM mrjj

            looks fine

            So MainWindow::newfile is called ?

            but newF is not shown or ?

            T Offline
            T Offline
            TETTRA
            wrote on last edited by TETTRA
            #5

            @mrjj Everything works. Just tell me how to do it the way I asked? if you know

            mrjjM 1 Reply Last reply
            0
            • T TETTRA

              @mrjj Everything works. Just tell me how to do it the way I asked? if you know

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @TETTRA
              I really dont understand what u ask, else i would tell you.

              void MainWindow::newfile() does nothing but showing the dialog so i dont understand your sentence

              "the window is open, but the button that called it does not work. Until the window disappears."

              But its not a button that calls it, its the QAction

              So i do not know what is not working.

              T 1 Reply Last reply
              2
              • mrjjM mrjj

                @TETTRA
                I really dont understand what u ask, else i would tell you.

                void MainWindow::newfile() does nothing but showing the dialog so i dont understand your sentence

                "the window is open, but the button that called it does not work. Until the window disappears."

                But its not a button that calls it, its the QAction

                So i do not know what is not working.

                T Offline
                T Offline
                TETTRA
                wrote on last edited by
                #7

                @mrjj In various programs there is a button that creates a new window in which you can for example draw and when creating this window a window appears that requests additional parameters (name, etc.) and that these windows would not have much, the button that called this window Is turned off. Like this.

                mrjjM 1 Reply Last reply
                0
                • T TETTRA

                  @mrjj In various programs there is a button that creates a new window in which you can for example draw and when creating this window a window appears that requests additional parameters (name, etc.) and that these windows would not have much, the button that called this window Is turned off. Like this.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @TETTRA said in Active window:

                  the button that called this window Is turned off

                  What you mean ? Like if u click it once, the window open. And the button is grey so u cant click on it again?
                  (before windows is closed ?)
                  is it to prevent to get multiple windows if u click many times on the button?

                  T 1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @TETTRA said in Active window:

                    the button that called this window Is turned off

                    What you mean ? Like if u click it once, the window open. And the button is grey so u cant click on it again?
                    (before windows is closed ?)
                    is it to prevent to get multiple windows if u click many times on the button?

                    T Offline
                    T Offline
                    TETTRA
                    wrote on last edited by
                    #9

                    @mrjj said in Active window:

                    What you mean ? Like if u click it once, the window open. And the button is grey so u cant click on it again?
                    (before windows is closed ?)
                    is it to prevent to get multiple windows if u click many times on the button?

                    Yes

                    mrjjM 1 Reply Last reply
                    0
                    • T TETTRA

                      @mrjj said in Active window:

                      What you mean ? Like if u click it once, the window open. And the button is grey so u cant click on it again?
                      (before windows is closed ?)
                      is it to prevent to get multiple windows if u click many times on the button?

                      Yes

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @TETTRA
                      You can use
                      button->setEnabled(false);
                      when you open dialog.

                      You must then catch when dialog closes and set button back to active.

                      T 1 Reply Last reply
                      2
                      • mrjjM mrjj

                        @TETTRA
                        You can use
                        button->setEnabled(false);
                        when you open dialog.

                        You must then catch when dialog closes and set button back to active.

                        T Offline
                        T Offline
                        TETTRA
                        wrote on last edited by TETTRA
                        #11

                        @mrjj

                        I tried, but I did not succeed, you can write.

                        mrjjM 1 Reply Last reply
                        0
                        • T TETTRA

                          @mrjj

                          I tried, but I did not succeed, you can write.

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by mrjj
                          #12

                          @TETTRA
                          What part did not work?

                          Here is sample using QDialog and a custom signal.
                          https://www.dropbox.com/s/7sjc6yz3zne395v/floatingdialog.zip?dl=0

                          T 1 Reply Last reply
                          2
                          • mrjjM mrjj

                            @TETTRA
                            What part did not work?

                            Here is sample using QDialog and a custom signal.
                            https://www.dropbox.com/s/7sjc6yz3zne395v/floatingdialog.zip?dl=0

                            T Offline
                            T Offline
                            TETTRA
                            wrote on last edited by
                            #13

                            @mrjj I'm sorru buet i really don't understand.

                            #include "newf.h"
                            #include "ui_newf.h"
                            #include <QWidget>
                            #include <QHBoxLayout>
                            #include <QVBoxLayout>
                            #include <QPushButton>
                            
                            #include "mainwindow.h"
                            #include "stylehelper.h"
                            #include "projectwindow.h"
                            
                            newF::newF(QWidget *parent) :
                                QDialog(parent),
                                ui(new Ui::newF)
                            {
                                ui->setupUi(this);
                            
                                this->setWindowFlags(Qt::SplashScreen);
                                this->setStyleSheet("QDialog {"
                                                    "background-color: #363636;"
                                                    "color: #FFFFFF;"
                                                    "}"
                                                    "QDialog::item:selected {"
                                                    "background-color: #6B6B6B"
                                                    "}");
                            
                                txt = new QLabel("New...",this);
                                txt->setGeometry(4, 4, 50, 10);
                                txt->setStyleSheet("QLabel {"
                                                   "color: #FFFFFF;"
                                                   "}");
                            
                                QPushButton *close = new QPushButton (this);
                                close->setGeometry(189, 1, 40, 18);
                                close->setStyleSheet("QPushButton {"
                                                     "image: url(:/images/close.png);"
                                                     "background-color: #000000;"
                                                     "border: none;"
                                                     "}"
                                                     "QPushButton:hover {"
                                                     "background-color: red; "
                                                     "}");
                                connect(close,SIGNAL(clicked()),this,SLOT(close()));
                            
                                newf = new QLabel("Name:",this);
                                newf->setStyleSheet("QLabel {"
                                                    "background-color: #363636;"
                                                    "color: #000000;"
                                                    "}");
                                name = new QLineEdit(this);
                                name->text();
                                name->setMaxLength(40);
                                name->setStyleSheet("QLineEdit {"
                                                    "color: #000000;"
                                                    "background-color: #696969;"
                                                    "border: 1px double black const;"
                                                    "};");
                                newf->setBuddy(name);
                                connect(name, &QLineEdit::textChanged, this, &newF::TextChanged);
                            
                                ok = new QPushButton("OK",this);
                                ok->setStyleSheet("QPushButton {"
                                                  "background-color: #696969;"
                                                  "border: none;"
                                                  "}"
                                                  "QPushButton:hover {"
                                                  "background-color: #7D7D7D;"
                                                  "}");
                                ok->setDefault(true);
                                ok->setEnabled(false);
                                ok->setFixedSize(100, 17);
                                connect(ok,&QPushButton::clicked,this,&newF::Ok);
                                QPushButton *cancel = new QPushButton("Cancel",this);
                                cancel->setStyleSheet("QPushButton {"
                                                      "background-color: #696969;"
                                                      "border: none;"
                                                      "}"
                                                      "QPushButton:hover {"
                                                      "background-color: #7D7D7D;"
                                                      "}");
                                cancel->setFixedSize(100, 17);
                                connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
                            
                                QHBoxLayout *hb1 = new QHBoxLayout;
                                hb1->addWidget(newf);
                                hb1->addWidget(name);
                                QHBoxLayout *hb = new QHBoxLayout;
                                hb->addWidget(ok);
                                hb->addWidget(cancel);
                                QVBoxLayout *vb = new QVBoxLayout;
                                vb->addLayout(hb1);
                                vb->addLayout(hb);
                            
                                setLayout(vb);
                            }
                            
                            newF::~newF()
                            {
                                delete ui;
                            }
                            
                            void newF::Ok(){
                                projectWindow *pw = new projectWindow();
                                pw->show();
                                close();
                            }
                            
                            void newF::paintEvent(QPaintEvent *event){
                                Q_UNUSED(event);
                                QPainter painter(this);
                                painter.setPen(QPen(Qt::black, 40, Qt::SolidLine, Qt::FlatCap));
                                painter.drawLine(0, 0, 230, 0);
                            
                            }
                            
                            void newF::mousePressEvent(QMouseEvent *event)
                            {
                                QPoint winPt  = this->pos();
                                QPoint mousePt = event->globalPos();
                            
                                m_Position = mousePt - winPt;
                            }
                            
                            
                            void newF::mouseMoveEvent(QMouseEvent *event)
                            {
                                this->move(event->globalPos() - m_Position);
                            }
                            
                            
                            void newF::TextChanged(QString){
                                QString names;
                                names = name->text();
                                if(names!="")
                                   ok->setEnabled(true);
                                else
                                   ok->setEnabled(false);
                            }
                            
                            
                              //create new file
                            void MainWindow::newfile(){
                                newF *newf = new newF();
                                newf->show();
                            }
                            
                                   //new
                                    newFile = new QAction (tr("New"),this);
                                      newFile->setShortcut(QKeySequence::New);
                                      connect(newFile,&QAction::triggered,this, &MainWindow::newfile);
                                      file->addAction(newFile);
                            
                            1 Reply Last reply
                            0
                            • mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              What part don't you understand ?
                              I put in comments in sample.

                              Ask about the places you are unsure about.

                              1 Reply Last reply
                              2

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved