Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    how to pass ui::windows as parameter.

    General and Desktop
    2
    2
    938
    Loading More Posts
    • 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.
    • R
      rafael last edited by rafael

      i have multiple windows created from ui_designer.

      window 1 for example is ui::window1 *ui
      and window 2 is ui::window2 *ui

      i want to update labels items located on the status bar for each indiviual ui.

      i created a class that has common code for all ui.

      is there a generic paremeter which i can pass to the function to make it take any ui or i just have to override each function to take a different window.

      ie ui::window1 *ui
      ui::window2 *ui

      footer( **** ui ****)
      {
      QPixmap cimage = QPixmap(":/images/OnOff.png");
      ui->closebutton->setPixmap(cimage);
      }

      each window inherits from the common class qobject.

      class Mainwindow : public QMainWindow, public common
      {

      }

      1 Reply Last reply Reply Quote 0
      • Chris Kawa
        Chris Kawa Moderators last edited by

        If common is a base class then it makes no sense that it would know about members of derived classes (the ui member). The type of that member is different for each derived class and they don't have a common base class so you can't get a "universal" pointer to it (apart from void* which you should definitely not do).

        One way to arrange this is make a pure virtual method in common that will return a button pointer i.e. virtual QPushButton* closeButton() = 0. then, in each derived class implement that method to return the button from its ui member. In your common class access the button via closeButtonmethod.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post