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. Main.cpp + mainwindow.ui = ??
Forum Updated to NodeBB v4.3 + New Features

Main.cpp + mainwindow.ui = ??

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.8k 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.
  • T Offline
    T Offline
    tecky
    wrote on last edited by
    #1

    i just need to know,
    is it possible to ".show()" my work in .ui and .cpp files in 1 window??
    for example:
    @
    #include "mainwindow.h"
    #include <QApplication>
    #include <QLabel>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    QLabel lbl("123");
    MainWindow w;
    w.show();
    lbl.show();

    return a.exec&#40;&#41;;
    

    }
    @
    (i added 2nd label in .UI file)

    1. can i display both of labels in 1 window?
    2. can i work (for exmpl, resize) 2nd lable by codding manually?
    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Yes, you just need to add your label to the layout in your MainWindow class. Just a couple of custom methods to expose the relevant layout (or clever reparenting :)) and it should work.

      (Z(:^

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tecky
        wrote on last edited by
        #3

        im newbie, so, ccan u write this lines?

        is it somthing like this?:
        ??->addWidget(lbl);

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          There are many ways. One would be:
          @
          lbl.setParent(mainWindow.centralWidget());
          @

          But I don't exactly know what the result would be. What I would do instead is to add method to your MainWIndow class that would expose one of the QLayout instances you have in the .ui and then add your label there. Sorry I won't write the code right now, it's 2 am in here now, I'm a tad too tired :D

          (Z(:^

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tecky
            wrote on last edited by
            #5

            ty
            it's works ok.
            but

            1. @ lbl.setParent(w.centralWidget());@
            2. after closing program error "Error - RtlWerpReportException failed with status code :-1073741823. Will try to launch the process directly"
            3. is it possible to siglnal /slot this 2 widgets?
            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