Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. copyavailable(), undoavailable()

copyavailable(), undoavailable()

Scheduled Pinned Locked Moved Unsolved Brainstorm
4 Posts 2 Posters 818 Views
  • 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
    tanim2607
    wrote on last edited by
    #1

    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

    jsulmJ 1 Reply Last reply
    0
    • T tanim2607

      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

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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
      2
      • jsulmJ jsulm

        @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

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

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

        jsulmJ 1 Reply Last reply
        0
        • T tanim2607

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

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #4

          @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
          1

          • Login

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