Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Problem with QTabWidget
Forum Update on Monday, May 27th 2025

Problem with QTabWidget

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
2 Posts 2 Posters 215 Views
  • 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.
  • E Offline
    E Offline
    Eleonore
    wrote on 13 May 2021, 10:32 last edited by
    #1

    Hello,
    I have to create a graphical interface with Qt but i have a problem with my QTabWdiget :
    In main.cpp :
    //Création de mes onglets
    QWidget Commander;

    QTabWidget*onglets = new QTabWidget(&Commander);
    onglets->setGeometry(1,1,1366,768);
    
    QWidget *page1=new QWidget;
    QWidget *page2= new QWidget;
    QWidget *page3=new QWidget;
    QWidget *page4= new QWidget;
    QWidget *page5=new QWidget;
    QWidget *page6= new QWidget;
    QWidget *page7=new QWidget;
    QWidget *page8= new QWidget;
    
      onglets->addTab(page1, "EN CE MOMENT");
      onglets->addTab(page2, "NOS MENUS");
      onglets->addTab(page3, "NOS SANDWICHS");
      onglets->addTab(page4, "PETITE FAIM");
      onglets->addTab(page5, "NOS BOISSONS");
      onglets->addTab(page6, "NOS DESSERTS");
      onglets->addTab(page7, "HAPPY MEAL");
      onglets->addTab(page8, "FRITES ET SAUCES");
    
    Commander.showMaximized();
    

    The first part of the code works, my tabs open correctly but it opens in another window next to it, as soon as my program is launched.
    My problem is that I created a class "order.h", when we are on the main window there is then a button "order" and when you click on the button a secondary window opens and I would like that when this secondary window opens it displays my tabs (from the code above).
    I tried to place my code directly in the "order.cpp" but nothing is displayed.
    How to do ?
    Thank's for you help.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 13 May 2021, 18:43 last edited by
      #2

      Hi and welcome to devnet,

      You should take a look at Qt layouts.

      However, from the looks of it you have an architecture issue. I would recommend drawing the various screens of your application. It will then be easier to build them and the business logique between them.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      1/2

      13 May 2021, 10:32

      • Login

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