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. Obtain QPushButton created in .ui file from another class

Obtain QPushButton created in .ui file from another class

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

    I currently have three classes: Page1,Page2 and Page_stackedWidget. On Page1.ui I have a QPushButton along with other widgets. On Page_stackedWidget.ui I created a stackedwidget which I include Page1 and Page2 and when I run the program, it works correctly. However, I would like it so when I press a button that is in page 1 it takes me to page 2. This is what I have for Page_stackedWidget.cpp

    #include "page_stackedwidget.h"
    #include "ui_page_stackedwidget.h"
    
    Page_stackedWidget::Page_stackedWidget(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
    }
    ui->setupUi(this);
    connect(Page1->nextButton, SIGNAL(clicked()),this,SLOT(goToPage2())); 
    }
    
    void Dialog::goToPage2()
    {
    ui->stackedWidget->setCurrentIndex(1);
    }
    

    However, the "nextButton" I created on the .ui file for Page1. I have looked for forums and i have found some similar to my problem but the difference is that their button is created on this file. http://stackoverflow.com/questions/9694474/manipulating-qt-ui-with-different-source-files.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      That question is already being answered here

      Let's keep it in only one place, closing this one.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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