Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. New Qwidget
QtWS25 Last Chance

New Qwidget

Scheduled Pinned Locked Moved Mobile and Embedded
5 Posts 3 Posters 6.3k 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.
  • T Offline
    T Offline
    tristenn
    wrote on last edited by
    #1

    Hi, can tell me pls anybody, whats wrong with this code :

    @#include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {

    ui->setupUi(this);
    
    QWidget *datawidget;
    
    datawidget = new QWidget();
    datawidget->setAccessibleName("datawidget");
    datawidget->setParent(ui->centralWidget);
    datawidget->resize(30,30);
    datawidget->setStyleSheet(" #datawidget { background-color:#000; } ");
    datawidget->show();
    datawidget->setVisible(true);
    

    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }
    @

    Thanks

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tristenn
      wrote on last edited by
      #2

      nothing showed.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alexander
        wrote on last edited by
        #3

        Try this:
        @MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
        {

        ui->setupUi(this);
        
        QWidget *datawidget = new QWidget( this );
        ui->setCentralWidget( datawidget );
        datawidget->setAccessibleName("datawidget");
        datawidget->setStyleSheet(" #datawidget { background-color:#000; } ");
        

        }

        MainWindow::~MainWindow()
        {
        delete ui;
        }@

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Franzk
          wrote on last edited by
          #4

          If you used a layout for your ui, you (c|sh)ould add the new widget to the layout.

          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • ? This user is from outside of this forum
            ? This user is from outside of this forum
            Guest
            wrote on last edited by
            #5

            Problem is with your setStyleSheet call ... use this instead

            @
            datawidget->setStyleSheet(" { background-color:#000; } ");
            @

            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