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 navigate with qwidget in qmainwindow
Forum Updated to NodeBB v4.3 + New Features

how to navigate with qwidget in qmainwindow

Scheduled Pinned Locked Moved Solved General and Desktop
4 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.
  • K Offline
    K Offline
    kevin32
    wrote on last edited by
    #1

    Hi everyone, can you help me?

    My problem is i have one mainwindow with qcentralwidget, when user click on a button, then personnal widget is load and in the widget you can access to other widget.

    To use that I use ```

    this->setCentralWidget(widget_acc);
    // clicked for display param widget
    QObject::connect(widget_acc, SIGNAL(Display_widget_param()),this, SLOT(display_widget_param()),Qt::UniqueConnection);
    
    with connect i handle display of other widget in slot :
    
    

    void accueil::display_widget_param(){
    this->param = new parametrage();
    // clicked for back in index widget
    QObject::connect(param, SIGNAL(Fermeture_parametrage()),this, SLOT(update_widget_accueil()),Qt::UniqueConnection);
    QObject::connect(param, SIGNAL(Lancer_video()),this, SLOT(Lancer_video()),Qt::UniqueConnection);
    this->setCentralWidget(param);
    }

    
    if i delete    this->param = new parametrage(); .
    

    QObject::connect: No such signal QObject::Fermeture_parametrage()
    QObject::connect: (sender name: 'parametrage')
    QObject::connect: (receiver name: 'accueil')

    I have my first widget display, after i click button its ok, after I click back button for display first screen but connect dont worked, like if param sender had reset?
    I don't understand beacause it's run one times and my widget is initialize in my mainwindow so he can't reset no?
    
    I saw Qstatewidget for navigate it's better solution for me? and why connect work 1 times and after no? 
    
    Thanks for you helping.
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @kevin32 said:
      hi
      Its not 100% clear for me what you are trying :)
      But
      setCentralWidget is special
      http://doc.qt.io/qt-5/qmainwindow.html#setCentralWidget
      "Note: QMainWindow takes ownership of the widget pointer and deletes it at the appropriate time."

      This means that widget_acc will be deleted when you call
      setCentralWidget(param); << u give it new, it deletes old.

      So if you try to go back to that Widget then it wont work.

      If you need something like pages. So in mainwindow, you switch between
      pages/screens, then QStackedWidget is super good for this.

      1 Reply Last reply
      1
      • K Offline
        K Offline
        kevin32
        wrote on last edited by
        #3

        Thanks it's work, they are good example here http://stackoverflow.com/questions/31501462/why-doesnt-setcentralwidget-work .

        mrjjM 1 Reply Last reply
        1
        • K kevin32

          Thanks it's work, they are good example here http://stackoverflow.com/questions/31501462/why-doesnt-setcentralwidget-work .

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @kevin32
          Yes that is indeed a good example. Thank you for posting.

          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