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. How to control a widget which created by UI Designer ?

How to control a widget which created by UI Designer ?

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

    Dear Sirs,

    I put a tabWidget on the MainWindow, this tabWidget is drag and drop from UI designer, so there is no "QTabWidget *tabWidget" declaration on the header file.

    Now I want to add a new tab by code, such as "tabWidget->addTab(button1, "Tab1");".
    Obviously there is no such widget for me to use, because this object is not declared before.

    What should I do ?

    Is there any way to tell compiler to find this object from UI designer ?

    Appreciate for any comments,

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      Hi Hiloshi,

      in your constructor you can use :

      MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
          ui->tabWidget->addTab(button1, "Tab1");"
      }
      

      The ui pointer is your gate to everything you defined in Qt Designer.

      Eddy

      Qt Certified Specialist
      www.edalsolutions.be

      H 1 Reply Last reply
      4
      • EddyE Eddy

        Hi Hiloshi,

        in your constructor you can use :

        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
            ui->tabWidget->addTab(button1, "Tab1");"
        }
        

        The ui pointer is your gate to everything you defined in Qt Designer.

        Eddy

        H Offline
        H Offline
        Hiloshi
        wrote on last edited by
        #3

        Dear @Eddy ,

        Yes, I should able do that. Thank you very much.

        Best Regarts,

        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