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 262 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.
  • S Offline
    S Offline
    Seb Tur
    wrote on 5 Mar 2024, 11:39 last edited by Seb Tur 3 May 2024, 11:41
    #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);

    J 1 Reply Last reply 5 Mar 2024, 11:54
    0
    • S Seb Tur
      5 Mar 2024, 11:39

      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);

      J Offline
      J Offline
      JonB
      wrote on 5 Mar 2024, 11:54 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.

      S 1 Reply Last reply 5 Mar 2024, 12:25
      0
      • J JonB
        5 Mar 2024, 11:54

        @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.

        S Offline
        S Offline
        Seb Tur
        wrote on 5 Mar 2024, 12:25 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.

        J 1 Reply Last reply 5 Mar 2024, 12:48
        0
        • S Seb Tur has marked this topic as solved on 5 Mar 2024, 12:25
        • S Seb Tur
          5 Mar 2024, 12:25

          @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.

          J Offline
          J Offline
          JonB
          wrote on 5 Mar 2024, 12:48 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

          1/4

          5 Mar 2024, 11:39

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved