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. promoted widget constructor not called
Forum Updated to NodeBB v4.3 + New Features

promoted widget constructor not called

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 295 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.
  • Seb TurS Offline
    Seb TurS Offline
    Seb Tur
    wrote on last edited by Seb Tur
    #1

    Hi
    I have a customized QTableView class with constructor as below

    iTableView::iTableView(QWidget *parent):
    QTableView(parent)
    {
    qDebug()<<Q_FUNC_INFO;
    }

    in QtDesigner I promoted a QTableView widget in my mainwindow ui to iTableView

    when I run program the constructor does not get called / no debug is visible

    I check ui_mainwindow.h and I can see
    rw = new QWidget();
    TV_rw = new iTableView(rw);

    JonBJ 1 Reply Last reply
    0
    • Seb TurS Seb Tur

      Hi
      I have a customized QTableView class with constructor as below

      iTableView::iTableView(QWidget *parent):
      QTableView(parent)
      {
      qDebug()<<Q_FUNC_INFO;
      }

      in QtDesigner I promoted a QTableView widget in my mainwindow ui to iTableView

      when I run program the constructor does not get called / no debug is visible

      I check ui_mainwindow.h and I can see
      rw = new QWidget();
      TV_rw = new iTableView(rw);

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Seb-Tur said in promoted widget constructor not called:

      TV_rw = new iTableView(rw);

      If this line is executed then iTableView::iTableView(QWidget *parent) will be called (assuming your class declaration in .h is correct and constructor shown is indeed read in) . Put a breakpoint on the calling line to see if it is hit?

      There is nothing special about designer code or promotion. You can see the .h files generated so then it is just C++ code. You will have to diagnose this yourself: do a clean rebuild, make sure the .cpp/.h/ui_....h files are all in the right place and it's not picking up an old one, etc.

      Seb TurS 1 Reply Last reply
      0
      • JonBJ JonB

        @Seb-Tur said in promoted widget constructor not called:

        TV_rw = new iTableView(rw);

        If this line is executed then iTableView::iTableView(QWidget *parent) will be called (assuming your class declaration in .h is correct and constructor shown is indeed read in) . Put a breakpoint on the calling line to see if it is hit?

        There is nothing special about designer code or promotion. You can see the .h files generated so then it is just C++ code. You will have to diagnose this yourself: do a clean rebuild, make sure the .cpp/.h/ui_....h files are all in the right place and it's not picking up an old one, etc.

        Seb TurS Offline
        Seb TurS Offline
        Seb Tur
        wrote on last edited by
        #3

        @JonB
        It was probably due to some kind of glitch that in global "promotions" dialog I had a customwidget with invalid header file specified to completely different class. It might have happended when I renamed my class files and I expect this is when it happened.

        Now all works I expected, thanks for trying to help and assuring me that it was nothing wrong in the code.

        JonBJ 1 Reply Last reply
        0
        • Seb TurS Seb Tur has marked this topic as solved on
        • Seb TurS Seb Tur

          @JonB
          It was probably due to some kind of glitch that in global "promotions" dialog I had a customwidget with invalid header file specified to completely different class. It might have happended when I renamed my class files and I expect this is when it happened.

          Now all works I expected, thanks for trying to help and assuring me that it was nothing wrong in the code.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Seb-Tur When you get "unexpected" behaviour in Qt program, first thing to try is a clean, complete rebuild because of stuff like this!

          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