Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to pass object to procedure
Qt 6.12 LTS is out! See what's new in the release blog

How to pass object to procedure

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.4k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I want a procedure. I want to pass ComboBox object name to it.
    @void MainWindow::addPowerUnitTypes(QComboBox *ComboBox)
    {
    ui->ComboBox->addItem("kilowatt [kW]");
    ui->ComboBox->addItem("horsepower [hp, hp (UK)]");
    }@

    And call the function
    @addPowerUnitTypes(ui->comboBoxFrom);@

    But I get an error: mainwindow.h:27: error: 'QComboBox' has not been declared.
    The line 27 of mainwindow.h is
    @void addPowerUnitTypes(QComboBox*);@

    I am totally new to this. I am Delphi programmer.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      welcome to devnet

      Did you include the header in mainwindow.h prior to line 27?

      @#include <QComboBox>@

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Ohh, I missed it indeed. Thank you.

        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
        • Unsolved