• 5929阅读
  • 3回复

[提问]为什么显示不了啊 [复制链接]

上一主题 下一主题
离线201021010623
 
只看楼主 倒序阅读 楼主  发表于: 2011-04-22
                        共有52人参与查看参与人员
                        
                            投票限制
                            
                                    
  1. 本投票只允许注册日期大于 2010-11-08 会员投票
  2.                             
                        
                        
1,九溪赏景+烧烤
                                    

                                
20(20%)
                                                                            sarabath 刘禅 李浩 叶小纨 喻春阳 竹青 吴芳 董宣 joey 凤来仪 郦善长 王华 钱文玲 吴鹃 朱以训 薛素素                                    
                                
2,爬山+中午自带干+分享+晚上聚餐(西湖边)
                                    

                                
10(10%)
3,真人CS
                                    

                                
50(50%)
4,其他(回帖注明)
                                    

                                
5(5%)
5,杭州乐园(新增项目)
                                    

                                
15(15%)
                        投票
                                            辩论结束时间 2014-12-31 14:39 — 裁判:admin
                                                    
正方观点(52%)
TX的确存在安全隐患TX的确存在安全隐患TX的确存在安全隐


反方观点(48%)
360 TMD无理取闹!
                        
                                                    
支持支持
                        
                                            
                        
类别婚庆类
发起时间2010-11-11 14:23
截止时间2010-11-12 14:23
人数限制100
报名限制所有用户
价格¥520
押金¥100
支付方式支付宝支付
联系人蜘蛛人,章鱼小姐
手机1596-0586-110
                    

#include <QtGui>
#include <mymainwindow.h>

mymainwindow::mymainwindow()
{
    setWindowTitle("key choice");
    setGeometry(100,100,610,520);

   mymain=new QWidget(this);
   mymain->resize(600,510);

   b1=new QPushButton("1",mymain);
   b1->setGeometry(10,30,100,40);
   b1->setFont(QFont("Times",18,QFont::Bold));

   b2=new QPushButton("2",mymain);
   b2->setGeometry(10,80,100,40);
   b2->setFont(QFont("Times",18,QFont::Bold));

   b3=new QPushButton("3",mymain);
   b3->setGeometry(10,130,100,40);
   b3->setFont(QFont("Times",18,QFont::Bold));

   b4=new QPushButton("4",mymain);
   b4->setGeometry(10,180,100,40);
   b4->setFont(QFont("Times",18,QFont::Bold));

   b5=new QPushButton("5",mymain);
   b5->setGeometry(10,230,100,40);
   b5->setFont(QFont("Times",18,QFont::Bold));

   b6=new QPushButton("6",mymain);
   b6->setGeometry(10,280,100,40);
   b6->setFont(QFont("Times",18,QFont::Bold));

   b7=new QPushButton("7",mymain);
   b7->setGeometry(10,330,100,40);
   b7->setFont(QFont("Times",18,QFont::Bold));

   b8=new QPushButton("8",mymain);
   b8->setGeometry(10,380,100,40);
   b8->setFont(QFont("Times",18,QFont::Bold));

   b9=new QPushButton("9",mymain);
   b9->setGeometry(10,430,100,40);
   b9->setFont(QFont("Times",18,QFont::Bold));

   tedit=new Q3MultiLineEdit(mymain);
   tedit->setGeometry(120,0,500,500);

   addChild(mymain);

   connect(b1,SIGNAL(clicked()),this,SLOT(mydisplay1()));
   connect(b2,SIGNAL(clicked()),this,SLOT(mydisplay2()));
   connect(b3,SIGNAL(clicked()),this,SLOT(mydisplay3()));
   connect(b4,SIGNAL(clicked()),this,SLOT(mydisplay4()));
   connect(b5,SIGNAL(clicked()),this,SLOT(mydisplay5()));
   connect(b6,SIGNAL(clicked()),this,SLOT(mydisplay6()));
   connect(b7,SIGNAL(clicked()),this,SLOT(mydisplay7()));
   connect(b8,SIGNAL(clicked()),this,SLOT(mydisplay8()));
   connect(b9,SIGNAL(clicked()),this,SLOT(mydisplay9()));

}
void mymainwindow::mydisplay1()
{
    tedit=new Q3MultiLineEdit(mymain);
    tedit->setGeometry(120,0,500,500);
    tedit->setReadOnly(true);

    QFile myfile("e:/mymainwindow/1.tex");
    myfile.open(IO_ReadOnly);
    QTextStream mystream(&myfile);
    QString mystring;
    while(mystream.atEnd()==0)
    {
        mystring=mystream.readLine();
        tedit->insertLine(mystring);
    }
    myfile.close();
}

void mymainwindow::mydisplay2()
{
    tedit=new Q3MultiLineEdit(mymain);
    tedit->setGeometry(120,0,500,500);
    tedit->setText("This is the second choice of text.");
    tedit->show();
}

void mymainwindow::mydisplay3()
{
    tedit=new Q3MultiLineEdit(mymain);
    tedit->setGeometry(120,0,500,500);
    tedit->setText("This is the third choice of text.");
    tedit->show();
}

void mymainwindow::mydisplay4()
{
    tedit=new Q3MultiLineEdit(mymain);
    tedit->setGeometry(120,0,500,500);
    tedit->setText("This is the fourth choice of text.");
    tedit->show();
}

void mymainwindow::mydisplay5()
{
    tedit=new Q3MultiLineEdit(mymain);
    tedit->setGeometry(120,0,500,500);
    tedit->setText("This is the fifth choice of text.");
    tedit->show();
}

void mymainwindow::mydisplay6()
{
    tedit=new Q3MultiLineEdit(mymain);
    tedit->setGeometry(120,0,500,500);
    tedit->setText("This is the sixth choice of text.");
    tedit->show();
}

void mymainwindow::mydisplay7()
{
    tedit=new Q3MultiLineEdit(mymain);
    tedit->setGeometry(120,0,500,500);
    tedit->setText("This is the seventh choice of text.");
    tedit->show();
}

void mymainwindow::mydisplay8()
{
    tedit=new Q3MultiLineEdit(mymain);
    tedit->setGeometry(120,0,500,500);
    tedit->setText("This is the eighth choice of text.");
    tedit->show();
}

void mymainwindow::mydisplay9()
{
    tedit=new Q3MultiLineEdit(mymain);
    tedit->setGeometry(120,0,500,500);
    tedit->setText("This is the ninth choice of text.");
    tedit->show();
}

按按钮1没反应




但是单独的程序#include <QApplication>
#include <QWidget>
#include <QFile>
#include <QTextStream>
#include <QString>
#include <Qt3Support/Q3MultiLineEdit>

class twelve1:public QWidget
{
public:
   twelve1();
private:
   Q3MultiLineEdit *medit;
};

twelve1::twelve1()
{
setGeometry(100,100,480,400);

medit=new Q3MultiLineEdit(this);
medit->setGeometry(10,10,460,380);
medit->setReadOnly(true);

  QFile myfile("e:/mymainwindow/1.txt");//文件的路径

myfile.open(IO_ReadOnly);//设置为只读模式

QTextStream mystream(&myfile);//这个对象从文件中读取文本

QString mystring;

while(mystream.atEnd()==0)//从文件中读取一行,并将它输出到QMultiLineEdit对象。
{
   mystring=mystream.readLine();//readline()每次只读一行,而read()读取整个流

   medit->insertLine(mystring);

}

myfile.close();

}

void main(int argc,char **argv)
{
   QApplication a(argc,argv);
   twelve1 w;
   w.show();
   a.exec();
}


可以显示。txt中的内容,为什么跟按钮在一起了就没用


请高手指教!
离线downstairs

只看该作者 1楼 发表于: 2011-04-22
因为按钮占据了整个item所以替换了原来的text对象
喜爱编程的猫头鹰
离线201021010623
只看该作者 2楼 发表于: 2011-04-22
回 1楼(downstairs) 的帖子
能教下怎么改吗
谢谢
离线downstairs

只看该作者 3楼 发表于: 2011-04-23
自己写继承自abstractbutton的控件 或继承自qwidget的控件呗。然后设置table控件为你的自定义控件
[ 此帖被downstairs在2011-04-23 00:39重新编辑 ]
喜爱编程的猫头鹰
快速回复
限100 字节
 
上一个 下一个