Hi All,
Apologies for the simple issue, but this is my first "outing" with Qt, and I haven't written any C code for about 7 years.
Not sure if I have a C problem or a Qt usage problem.
I'm getting the PC netbios name and then wanting to display it on mu ui.
When I use hostname, I get an error relating to incorrect data type. The debugger does show that hostname contains my PC name.
I then (think that I) point a QSting variable to the address of hostname, and only the first character of hostname appears on my ui.
Please can someone spot my deliberate mistake.
Thanks & regards,
Zoltan.
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "windows.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
WCHAR hostname[12];
QString nam = "";
DWORD len;
len = 12;
hostname[11] = '\0';
GetComputerName(hostname,&len);
nam = (char *)&hostname[0];
ui->name_pc->setText(nam);
}
MainWindow::~MainWindow()
{
delete ui;
}
Bookmarks