Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved copyavailable(), undoavailable()

    Brainstorm
    2
    4
    500
    Loading More Posts
    • 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
      tanim2607 last edited by

      can anyone explain copyavailable() and undoredoavaiable() functions with some code?? and what's wrong with this code??
      void MainWindow::on_actioncopy_triggered()
      {
      if(ui->textEdit->copyAvailable((bool))){
      ui->textEdit->copy();
      else{
      QMessageBox::information(this,"FYI","Select something first");}

      }

      void MainWindow::on_actionpaste_triggered()
      {
      if(ui->textEdit->canPaste())
      ui->textEdit->paste();
      else
      QMessageBox::information(this,"FYI","Copy something first");
      }

      void MainWindow::on_actioncut_triggered()
      {
      if(ui->textEdit->copyAvailable(isEnabled()))
      ui->textEdit->cut();
      else
      QMessageBox::
      information(this,"FYI","Select something first");
      }

      void MainWindow::on_actionundo_triggered()
      {
      if(ui->textEdit->undoAvailable() == true)
      ui->textEdit->setUndoRedoEnabled(isEnabled());
      else
      QMessageBox::
      information(this,"FYI","nothing to undo");
      }
      if any edit needed, plz feel free to suggest

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @tanim2607 last edited by

        @tanim2607 This code does not make sense.
        copyAvailable is a SIGNAL and does not return a boolean, also "if(ui->textEdit->copyAvailable((bool))){" is not valid C++ code. You need to connect a slot to copyAvailable. Read https://doc.qt.io/qt-5/signalsandslots.html
        Please read https://doc.qt.io/qt-5/qtextedit.html#copyAvailable

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        T 1 Reply Last reply Reply Quote 2
        • T
          tanim2607 @jsulm last edited by

          @jsulm i sort of know, can u correct the code for me?? i saw the document, bt can't get a hold of it....

          jsulm 1 Reply Last reply Reply Quote 0
          • jsulm
            jsulm Lifetime Qt Champion @tanim2607 last edited by jsulm

            @tanim2607 said in copyavailable(), undoavailable():

            can u correct the code for me??

            It's your job.
            As I wrote: connect a slot to copyAvailable signal.
            If you have problems/don't understand something then ask concrete questions. But don't ask others to write code for you - you will hardly learn anything this way...

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 1
            • First post
              Last post