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. [RESOLVED] use UI element in functions
Forum Updated to NodeBB v4.3 + New Features

[RESOLVED] use UI element in functions

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 790 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.
  • M Offline
    M Offline
    mrcgnerd
    wrote on last edited by
    #1

    How can I use UI elements in my functions ?
    For example:

    @void MainWindow::MyFunc (QTableview MyTable)
    {
    ui->MyTable->setenabled(true);
    }

    /////////////////////////////////////////////////////////////////

    void MainWindow::on_pushButton_clicked()
    {
    MyFunc(ui->table1);
    }
    @

    Thank you, and sory for my english.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      You did it almost right.
      Here is fixed version.
      @
      // You pass a pointer to the function
      void MainWindow::MyFunc (QTableView* MyTable)
      {
      // Here you use that pointer.
      MyTable->setEnabled(true);
      }

      /////////////////////////////////////////////////////////////////
      void MainWindow::on_pushButton_clicked()
      {
      // I assume that ui->table1 is QTableView*
      MyFunc(ui->table1);
      }
      @

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mrcgnerd
        wrote on last edited by
        #3

        Oh a pointer, of corse !

        Yes table1 is QTableview*
        Now it's working :)

        THANK YOU WERY MUCH !

        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