Qt获取本机IP、主机名及当前时间

阿紫 posted @ 2012年7月25日 18:28 in Qt , 9755 阅读

获取本机ip:

 

QString m_ip;

QHostInfo host = QHostInfo::fromName(QHostInfo::localHostName());

foreach (QHostAddress address, host.addresses());

m_ip = address.toString();

获取主机名:

 

#pragma comment(lib,"ws2_32.lib")//相当于把ws2_32.lib这个库加入到了工程文件中,同setting中加入库效果一样


//获取计算机名

WSAData data;
if(WSAStartup(MAKEWORD(1,1),&data)!=0)
{
	cout<<"初始化错误,无法获取主机信息..."<<endl ;
}

wchar_t chBuffer[20];
DWORD dwSize=20;
if(!GetComputerName(chBuffer,&dwSize))
{

	QMessageBox::warning(0,QObject::tr("error"), QObject::tr("get computername error!"),QMessageBox::Ok);
}
strName=QString::fromWCharArray(chBuffer);
	

获取当前时间:

 

#include<QDateTime>

void mainwindow::gettime()
{
	QDateTime dateTime = QDateTime::currentDateTime();
	int y=dateTime.date().year();
	int m=dateTime.date().month();
	int d=dateTime.date().day();
	QString strTime=dateTime.time().toString();
	stime=(strTime+"   "+QString::number(y)+"/"+QString::number(m)+"/"+QString::number(d));
}

滚动条保持在最底端:

 

recEdit->moveCursor(QTextCursor::End,QTextCursor::KeepAnchor);
recEdit->verticalScrollBar()->setValue(recEdit->verticalScrollBar()->maximumHeight());
  • 无匹配
Avatar_small
依云 说:
2012年7月25日 21:55

第二段代码用的是 Win32 API,可不是 Qt,也不跨平台哦。

Avatar_small
阿紫 说:
2012年7月25日 22:20

嗯,这个确实,只是整理了下以前写的东西,以前也只是用在win下,也没考虑那么多

地里的 说:
2012年9月17日 12:46

那个获取当前时间的完全可以使用一行代码搞定!
QDateTime::currentDateTime().toString("hh-mm-ss yyyy/MM/dd");

地里的 说:
2012年9月17日 13:30

获取主机名称也是一行代码:
QHostInfo::localHostName();

seo service UK 说:
2023年11月02日 16:27

I am very happy to finally read about the Thank you very much. Your post was of great help to me. If you are interested in the column I wrote, please visit my site . You’re brilliant! Thank you! I experience the beneficial data you offer for your articles. Fantastic blog! I dont assume ive visible all the angles of this situation the way youve pointed

토토사이트가입코드 说:
2023年11月07日 13:46

This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! Keep up the good work.World Facts For Children… […]here are some links to sites that we link to because we think they are worth visiting[…]…

사설토토 说:
2023年11月07日 13:50

 was wondering if you ever thought of changing the page layout of your site? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or 2 images. Maybe you could space it out better?|

놀이터검문소 说:
2023年11月07日 14:58

I think this is one of the most vital info for me. And i’m glad studying your article. However should observation on few general things, The web site style is perfect, the articles is in reality excellent : D. Just right activity, cheers| This is a topic which is near to my heart… Take care! Exactly where are your contact details though?|

승인전화없는 토토꽁머니 说:
2023年11月07日 14:58

It’s the best time to make a few plans for the longer term and it is time to be happy. I have learn this post

먹튀검증소먹튀검증 说:
2023年11月07日 15:13

I am extremely impressed with your writing skills as well as with the layout on your weblog. Is this a paid theme or did you customize it yourself? Either way keep up the nice quality writing, it’s rare to see a great blog like this one these days.| Informative, pretty much as I had come to expect from this site.

벳매니아배너 说:
2023年11月07日 15:13

After study several of the web sites for your website now, and that i truly such as your technique of blogging. I bookmarked it to my bookmark website list and are checking back soon. Pls consider my website at the same time and make me aware if you agree.

가족방오픈카톡 说:
2023年11月07日 15:57

Does your blog have a contact page? I’m having a tough time locating it but, I’d like to shoot you an e-mail. I’ve got some ideas for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it grow over time.|

메이저사이트검증 说:
2023年11月07日 15:58

Can I simply say what a reduction to search out someone who really is aware of what theyre talking about on the internet. You definitely know easy methods to carry a problem to mild and make it important. More people must read this and understand this aspect of the story. I cant believe youre no more popular because you definitely have the gift.

토토 배너사이트 说:
2023年11月07日 16:07

Greetings, I think your blog could be having internet browser compatibility issues. When I look at your website in Safari, it looks fine however, when opening in IE, it has some overlapping issues. I merely wanted to give you a quick heads up! Apart from that, great website!|

메이저놀이터주소 说:
2023年11月07日 16:11

it is a really nice point of view. I usually meet people who rather say what they suppose

안전놀이터가입 说:
2023年11月07日 16:22

Does your blog have a contact page? I’m having a tough time locating it but, I’d like to shoot you an e-mail. I’ve got some ideas for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it grow over time.|

하이브카지노주소 说:
2023年11月07日 16:22

It’s the best time to make a few plans for the longer term and it is time to be happy. I have learn this post and if I may just I wish to counsel you few attention-grabbing issues or advice. Maybe you can write next articles relating to this article. I wish to read even more things approximately it!|

먹튀검증 说:
2023年11月07日 16:38

Greetings, I think your blog could be having internet browser compatibility issues. When I look at your website in Safari, it looks fine however, when opening in IE, it has some overlapping issues. I merely wanted to give you a quick heads up! Apart from that, great website!|

타이산카지노특징 说:
2023年11月07日 16:52

An impressive share, I just given this onto a colleague who had previously been performing a small analysis on this. And hubby in fact bought me breakfast simply because I found it for him.. smile. So permit me to reword that: Thnx for

타이산카지노특징 说:
2023年11月07日 16:53

An impressive share, I just given this onto a colleague who had previously been performing a small analysis on this. And hubby in fact bought me breakfast simply because I found it for him.. smile. So permit me to reword that: Thnx for the treat! But yeah Thnkx for spending any time go over this, I find myself strongly regarding this and really like reading much more about this topic. If you can, as you grow expertise, does one mind updating your blog post with increased details? It can be extremely helpful for me. Massive thumb up with this blog post!

먹튀검증 说:
2023年11月07日 16:57

Does your blog have a contact page? I’m having a tough time locating it but, I’d like to shoot you an e-mail. I’ve got some ideas for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it grow over time.|

토토사이트 说:
2023年11月07日 16:59

Nice post. I discover something tougher on various blogs everyday. Most commonly it is stimulating to see content off their writers and practice a little there. I’d would prefer to use some using the content on my own weblog whether you do not mind. Natually I’ll supply you with a link with your web blog. Thanks for sharing.

토스타 说:
2023年11月07日 17:09

Hi are using WordPress for your blog platform? I’m new to the blog world but I’m trying to get started and create my own. Do you require any coding knowledge to make your own blog? Any help would be really appreciated!| I have read so many posts concerning the blogger lovers however this paragraph is in fact a fastidious article, keep it up.|

온라인카지노 说:
2023年11月07日 17:24

Hi there I am so excited I found your webpage, I really found you by error, while I was researching on Askjeeve for something else, Anyhow I am here now and would just like to say thank you for a incredible post and a all round interesting blog (I also love the theme/design), I don’t have time to look over it all at the minute but I have saved it and also added in your RSS feeds, so when I have time I will be back to read much more, Please do keep up the awesome work.|

บาคาร่า 说:
2023年11月07日 17:51

I do consider all of the ideas you have presented on your post. They’re very convincing and can certainly work. Still, the posts are very quick for novices. May

먹튀신고 说:
2023年11月07日 17:58

After study several of the web sites for your website now, and that i truly such as your technique of blogging. I bookmarked it to my bookmark website list and are checking back soon. Pls consider my website at the same time and make me aware if you agree.

먹튀사이트 说:
2023年11月07日 18:02

After study several of the web sites for your website now, and that i truly such as your technique of blogging.

토토검증사이트 说:
2023年11月07日 18:15

I think this is one of the most vital info for me. And i’m glad studying your article. However should observation on few general things, The web site style is perfect, the articles is in reality excellent : D. Just right activity, cheers| This is a topic which is near to my heart… Take care! Exactly where are your contact details though?|

토토사이트 说:
2023年11月07日 18:19

Today, I went to the beachfront with my kids. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is completely off topic but I had to tell someone!|

에볼루션코리아 说:
2023年11月07日 18:24

After study several of the web sites for your website now, and that i truly such as your technique of blogging. I bookmarked it to my bookmark website list and are checking back soon. Pls consider my website at the same time and make me aware if you agree.

바카라사이트추천 说:
2023年11月07日 18:48

Being grateful for for your post. I know that within today’s complicated world, folks have many beliefs and this has made it to be really hard for learners just like me. However, you have made the idea very easy for me to comprehend and I now know the correct thing. Your continued reputation among the top experts with this topic may be enhanced through words of appreciation from followers like me. Thanks, once more.

바로벳 주소 说:
2023年11月07日 18:50

Does your blog have a contact page? I’m having a tough time locating it but, I’d like to shoot you an e-mail. I’ve got some ideas for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it grow over time.|

바로벳 주소 说:
2023年11月07日 18:54

Does your blog have a contact page? I’m having a tough time locating it but, I’d like to shoot you an e-mail. I’ve got some ideas for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it grow over time.|

파라오카지노 说:
2023年11月07日 18:55

Hey! Someone in my Facebook group shared this website with us so I came to give it a look. I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers! Terrific blog and amazing design.| You reported this exceptionally well! fda kratom

먹튀검증업체 说:
2023年11月07日 19:06

Hey! Someone in my Facebook group shared this website with us so I came to give it a look. I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers! Terrific blog and amazing design.| You reported this exceptionally well! fda kratom

먹튀폴리스 说:
2023年11月07日 19:06

Greetings, I think your blog could be having internet browser compatibility issues. When I look at your website in Safari, it looks fine however, when opening in IE, it has some overlapping issues. I merely wanted to give you a quick heads up! Apart from that, great website!|

안전놀이터가입 说:
2023年11月07日 19:29

Hi are using WordPress for your blog platform? I’m new to the blog world but I’m trying to get started and create my own. Do you require any coding knowledge to make your own blog? Any help would be really appreciated!| I have read so many posts concerning the blogger lovers however this paragraph is in fact a fastidious article, keep it up.|

메이저사이트 특징 说:
2023年11月07日 19:40

Hi there I am so excited I found your webpage, I really found you by error, while I was researching on Askjeeve for something else, Anyhow I am here now and would just like to say thank you for a incredible post and a all round interesting blog (I also love the theme/design), I don’t have time to look over it all at the minute but I have saved it and also added in your RSS feeds, so when I have time I will be back to read much more, Please do keep up the awesome work.|

토토사이트추천 说:
2023年11月07日 19:56

Hello, Neat post. There’s a problem along with your web site in internet explorer, would test this? IE nonetheless is the market leader and a huge element of folks will pass over your great writing due to this problem.|so I only wanted to offer a fast shout out and claim I genuinely enjoy studying your articles. Could you suggest any other blogs/websites/forums that will deal with the identical subjects? Thanks.

안전공원주소 说:
2023年11月07日 19:57

Just wish to say your article is as amazing. The clarity in your post is just nice and i could assume you are an expert on this subject. Fine with your permission allow me to grab your RSS feed to keep updated with forthcoming post. Thanks a million and please continue the rewarding work.|

토토커뮤니티 说:
2023年11月07日 20:31

Hi are using WordPress for your blog platform? I’m new to the blog world but I’m trying to get started and create my own. Do you require any coding knowledge to make your own blog? Any help would be really appreciated!| I have read so many posts concerning the blogger lovers however this paragraph is in fact a fastidious article, keep it up.|

토토커뮤니티 说:
2023年11月07日 20:50

Sweet blog! I found it while browsing on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Cheers| Hi. i think that you should add captcha to your blog.

먹튀사이트 说:
2024年1月15日 15:17

This is important, though it's necessary to help you head over to it weblink:

슬롯커뮤니티 说:
2024年1月15日 17:22

Thanks for making the sincere attempt to explain this. I think very robust about it and want to learn more. If it’s OK, as you attain more extensive knowledge

토토사이트 说:
2024年1月15日 18:23

You have a good point here!I totally agree with what you have said!!Thanks for sharing your views...hope more people will read this article!!

소액결제현금화 说:
2024年1月15日 18:42

Very good blog post.Much thanks again. Cool.

카지노사이트 说:
2024年1月15日 19:08

I went over this website and I believe you have a lot of wonderful information, saved to my bookmarks

스포츠무료중계 说:
2024年1月15日 19:20

This is a fabulous post I seen by virtue of offer it. It is genuinely what I expected to see look for in future you will continue subsequent to sharing such an extraordinary post

카지노사이트 说:
2024年1月15日 20:06

Very interesting blog. Alot of blogs I see these days don't really provide anything that I'm interested in, but I'm most definately interested in this one. Just thought that I would post and let you know.

ios industrial real 说:
2024年1月15日 20:12

It is a completely interesting blog publish.I often visit your posts for my project's help about Diwali Bumper Lottery and your super writing capabilities genuinely go away me taken aback.Thank you a lot for this publish.

토토사이트 说:
2024年1月15日 20:45

Your blog provided us with valuable information to work with. Each & every tips of your post are awesome. Thanks a lot for sharing. Keep blogging,

슬롯사이트 说:
2024年1月16日 13:30

Nice Informative Blog having nice sharing..

바카라사이트 说:
2024年1月16日 14:01

Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place..

바카라 커뮤니티 说:
2024年1月16日 16:47

Excellent post. I want to thank you for this informative read, I really appreciate sharing this great post. Keep up your work

카지노 커뮤니티 说:
2024年1月16日 17:37

Thumbs up guys your doing a really good job

카지노사이트 说:
2024年1月18日 13:50

I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work.

메이저사이트 说:
2024年1月18日 16:15

wow this saintly however ,I love your enter plus nice pics might be part personss negative love being defrent mind total poeple

바카라 사이트 추천 说:
2024年1月22日 11:44

온라인 카지노 커뮤니티 온카허브 입니다. 온카허브는 카지노 먹튀 사이트들과 안전한 카지노 사이트 정보를 공유하고 있습니다. 카지노 먹튀검증 전문팀을 자체적으로 운영함으로써 철저한 검증을 진행하고 있습니다.
https://oncahub24.com/

온라인 카지노 먹튀 说:
2024年1月22日 12:22

온라인 카지노 커뮤니티 온카허브 입니다. 온카허브는 카지노 먹튀 사이트들과 안전한 카지노 사이트 정보를 공유하고 있습니다. 카지노 먹튀검증 전문팀을 자체적으로 운영함으로써 철저한 검증을 진행하고 있습니다.

카지노 说:
2024年1月23日 17:41

카지노 우리카지노 카지노는 바카라, 블랙잭, 룰렛 및 슬롯 등 다양한 게임을 즐기실 수 있는 공간입니다. 게임에서 승리하면 큰 환호와 함께 많은 당첨금을 받을 수 있고, 패배하면 아쉬움과 실망을 느끼게 됩니다.

바카라 사이트 추천 说:
2024年1月23日 17:48

하노이 꼭 가봐야 할 베스트 업소 추천 안내 및 예약, 하노이 밤문화 에 대해서 정리해 드립니다. 하노이 가라오케, 하노이 마사지, 하노이 풍선바, 하노이 밤문화를 제대로 즐기시기 바랍니다. 하노이 밤문화 베스트 업소 요약 베스트 업소 추천 및 정리. zeiffummeipollou-3171@yopmail.com

먹튀사이트 说:
2024年1月25日 11:26

No.1 먹튀검증 사이트, 먹튀사이트, 검증사이트, 토토사이트, 안전사이트, 메이저사이트, 안전놀이터 정보를 제공하고 있습니다. 먹튀해방으로 여러분들의 자산을 지켜 드리겠습니다. 먹튀검증 전문 커뮤니티 먹튀클린만 믿으세요!!

베트남 밤문화 说:
2024年1月25日 15:02

베트남 남성전용 커뮤니티❣️ 베트남 하이에나 에서 베트남 밤문화를 추천하여 드립니다. 베트남 가라오케, 베트남 VIP마사지, 베트남 이발관, 베트남 황제투어 남자라면 꼭 한번은 경험 해 봐야할 화끈한 밤문화로 모시겠습니다. 


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter